commit aedd643d35d586f8938f647a0a6bf5bf2321301a Author: KNEMC <2014539504@qq.com> Date: Fri Aug 7 19:33:10 2026 +0800 JavaOpenCL64 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..5b2b3e0 --- /dev/null +++ b/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..5bca898 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + JavaOpenCL64 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b143cd5 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,15 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=18 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=18 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=18 diff --git a/libs/annotations-26.1.0-javadoc.jar b/libs/annotations-26.1.0-javadoc.jar new file mode 100644 index 0000000..279fd0b Binary files /dev/null and b/libs/annotations-26.1.0-javadoc.jar differ diff --git a/libs/annotations-26.1.0-sources-common.jar b/libs/annotations-26.1.0-sources-common.jar new file mode 100644 index 0000000..6737701 Binary files /dev/null and b/libs/annotations-26.1.0-sources-common.jar differ diff --git a/libs/annotations-26.1.0.jar b/libs/annotations-26.1.0.jar new file mode 100644 index 0000000..db6f432 Binary files /dev/null and b/libs/annotations-26.1.0.jar differ diff --git a/libs/bcel-6.10.0-javadoc.jar b/libs/bcel-6.10.0-javadoc.jar new file mode 100644 index 0000000..c85d662 Binary files /dev/null and b/libs/bcel-6.10.0-javadoc.jar differ diff --git a/libs/bcel-6.10.0-sources.jar b/libs/bcel-6.10.0-sources.jar new file mode 100644 index 0000000..d36fc83 Binary files /dev/null and b/libs/bcel-6.10.0-sources.jar differ diff --git a/libs/bcel-6.10.0.jar b/libs/bcel-6.10.0.jar new file mode 100644 index 0000000..a75c637 Binary files /dev/null and b/libs/bcel-6.10.0.jar differ diff --git a/libs/ffm-plus-0.2.7-javadoc.jar b/libs/ffm-plus-0.2.7-javadoc.jar new file mode 100644 index 0000000..1becfc9 Binary files /dev/null and b/libs/ffm-plus-0.2.7-javadoc.jar differ diff --git a/libs/ffm-plus-0.2.7-sources.jar b/libs/ffm-plus-0.2.7-sources.jar new file mode 100644 index 0000000..cb5eaaa Binary files /dev/null and b/libs/ffm-plus-0.2.7-sources.jar differ diff --git a/libs/ffm-plus-0.2.7.jar b/libs/ffm-plus-0.2.7.jar new file mode 100644 index 0000000..9b52e21 Binary files /dev/null and b/libs/ffm-plus-0.2.7.jar differ diff --git a/libs/opencl-0.4.4-javadoc.jar b/libs/opencl-0.4.4-javadoc.jar new file mode 100644 index 0000000..ca9464a Binary files /dev/null and b/libs/opencl-0.4.4-javadoc.jar differ diff --git a/libs/opencl-0.4.4-sources.jar b/libs/opencl-0.4.4-sources.jar new file mode 100644 index 0000000..43f57af Binary files /dev/null and b/libs/opencl-0.4.4-sources.jar differ diff --git a/libs/opencl-0.4.4.jar b/libs/opencl-0.4.4.jar new file mode 100644 index 0000000..c6f57ea Binary files /dev/null and b/libs/opencl-0.4.4.jar differ diff --git a/src/club/doki7/ffm/FunctionLoader.java b/src/club/doki7/ffm/FunctionLoader.java new file mode 100644 index 0000000..04edf79 --- /dev/null +++ b/src/club/doki7/ffm/FunctionLoader.java @@ -0,0 +1,15 @@ +package club.doki7.ffm; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.FunctionDescriptor; +import java.lang.invoke.MethodHandle; + +@FunctionalInterface +public interface FunctionLoader { + @Nullable MethodHandle apply( + @NotNull String name, + @NotNull FunctionDescriptor descriptor + ); +} diff --git a/src/club/doki7/ffm/IPointer.java b/src/club/doki7/ffm/IPointer.java new file mode 100644 index 0000000..4f7e037 --- /dev/null +++ b/src/club/doki7/ffm/IPointer.java @@ -0,0 +1,26 @@ +package club.doki7.ffm; + +import club.doki7.ffm.annotation.ValueBasedCandidate; +import club.doki7.ffm.ptr.IntPtr; +import org.jetbrains.annotations.NotNull; + +import java.lang.foreign.MemorySegment; + +/// Represents a pointer to native memory. +@ValueBasedCandidate +public interface IPointer { + /// The implementation should always provide a not-null {@link MemorySegment} + /// ({@code segment() != null && !segment().equals(MemorySegment.NULL)}). The segment must be + /// properly aligned according to the pointee type. To represent null pointer, user + /// should use a Java {@code null} {@link IPointer}. + /// + /// Generally speaking, the segment's size does not need to be multiple of the size of the + /// pointee type. For example, a {@link IntPtr} can point to a segment of + /// 7 bytes. The trailing bytes can be safely ignored by most algorithms and FFI functions. + /// + /// If the memory segment is even not big enough to hold a single element of the pointee type, + /// the segment is simply considered "empty". This is just like allocating 0 bytes with C/C++ + /// {@code malloc(0)} (on some implementation): the resulting pointer is not {@code NULL} and + /// valid, but you cannot read or write anything. + @NotNull MemorySegment segment(); +} diff --git a/src/club/doki7/ffm/LibcArena.java b/src/club/doki7/ffm/LibcArena.java new file mode 100644 index 0000000..3f01861 --- /dev/null +++ b/src/club/doki7/ffm/LibcArena.java @@ -0,0 +1,189 @@ +package club.doki7.ffm; + +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.library.JavaSystemLibrary; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.util.Objects; + +public enum LibcArena implements Arena { + INSTANCE; + + /// Allocates memory using system libc {@code aligned_alloc} + /// + /// Note that you're in charge of freeing the memory using {@link LibcArena#free}, otherwise + /// there will be a memory leak. Be extra careful when using {@link LibcArena} in combination + /// with `allocate` series methods. + /// + /// @param byteSize The size of the memory to allocate + /// @param byteAlignment The alignment of the memory to allocate + /// @return A {@link MemorySegment} representing the allocated memory with all bytes zeroed + /// @throws IllegalArgumentException If the byte size or alignment is invalid + /// @throws OutOfMemoryError If the memory allocation fails + @Override + public @NotNull MemorySegment allocate(long byteSize, long byteAlignment) { + if (byteSize <= 0 || byteAlignment <= 0 || (byteAlignment & (byteAlignment - 1)) != 0) { + throw new IllegalArgumentException("Invalid byte size or alignment"); + } + + if (HANDLE$aligned_alloc == null) { + return allocateLegacy(byteSize, byteAlignment); + } + + MemorySegment ms; + try { + ms = (MemorySegment) HANDLE$aligned_alloc.invokeExact( + MemorySegment.ofAddress(byteAlignment), + MemorySegment.ofAddress(byteSize) + ); + } catch (Throwable e) { + throw new RuntimeException("Failed to allocate memory", e); + } + + if (ms.equals(MemorySegment.NULL)) { + throw new OutOfMemoryError("Failed allocating memory with aligned_alloc"); + } + + ms = ms.reinterpret(byteSize); + ms.fill((byte) 0); + return ms; + } + + /// Frees memory that was allocated by {@link LibcArena#allocate(long, long)}. + /// + /// @param ms The memory segment to free + public void free(@NotNull MemorySegment ms) { + if (ms.equals(MemorySegment.NULL)) { + return; + } + + if (HANDLE$aligned_alloc == null) { + freeLegacy(ms); + return; + } + + try { + Objects.requireNonNull(HANDLE$free).invokeExact(ms); + } catch (Throwable e) { + throw new RuntimeException("Failed to free memory", e); + } + } + + /// Frees memory that was allocated by libc allocator, but not via + /// {@link LibcArena#allocate(long, long)}. + /// + /// Some libraries, like `stb_vorbis`, may allocate memory using libc allocators internally, and + /// require you to free that memory using `free` from the same libc implementation. The best way + /// to do this is to use the `free` method encapsulation provided by that library integration. + /// But if that is not available, this method can be used as an alternative with some risk. + /// + /// This function is marked as {@link Unsafe}, because if the memory was not exactly allocated + /// by the same allocator {@link LibcArena} found, it will lead to undefined behavior. This + /// relates with platforms, build system and many other factors. Double check before really + /// doing this. + @Unsafe + public void freeNonAllocated(@NotNull MemorySegment ms) { + if (ms.equals(MemorySegment.NULL)) { + return; + } + + try { + Objects.requireNonNull(HANDLE$free).invokeExact(ms); + } catch (Throwable e) { + throw new RuntimeException("Failed to free non-allocated memory", e); + } + } + + @Override + public @Nullable MemorySegment.Scope scope() { + return null; + } + + @Override + public void close() { + throw new UnsupportedOperationException("Cannot close LibcArena"); + } + + private static MemorySegment allocateLegacy(long byteSize, long byteAlignment) { + final long pointerSize = ValueLayout.ADDRESS.byteSize(); + final long totalSize = byteSize + byteAlignment - 1 + pointerSize; + + MemorySegment rawMS; + try { + MethodHandle hMalloc = Objects.requireNonNull(HANDLE$malloc); + rawMS = (MemorySegment) hMalloc.invokeExact(MemorySegment.ofAddress(totalSize)); + } catch (Throwable e) { + throw new RuntimeException("Failed to allocate memory using malloc", e); + } + + if (rawMS.equals(MemorySegment.NULL)) { + throw new OutOfMemoryError("Failed allocating memory with malloc"); + } + + final long rawAddress = rawMS.address(); + final long alignedAddress = (rawAddress + pointerSize + byteAlignment - 1) & -byteAlignment; + final long metadataAddress = alignedAddress - pointerSize; + + MemorySegment ms = MemorySegment.ofAddress(alignedAddress).reinterpret(byteSize); + MemorySegment metadata = MemorySegment.ofAddress(metadataAddress).reinterpret(pointerSize); + metadata.set(ValueLayout.ADDRESS, 0, rawMS); + ms.fill((byte) 0); + + return ms; + } + + private static void freeLegacy(@NotNull MemorySegment ms) { + if (ms.equals(MemorySegment.NULL)) { + return; + } + + final long pointerSize = ValueLayout.ADDRESS.byteSize(); + final long metadataAddress = ms.address() - pointerSize; + MemorySegment metadata = MemorySegment.ofAddress(metadataAddress).reinterpret(pointerSize); + MemorySegment rawMS = metadata.get(ValueLayout.ADDRESS, 0); + + if (rawMS.equals(MemorySegment.NULL)) { + throw new IllegalStateException("Memory segment does not have allocated memory"); + } + + try { + Objects.requireNonNull(HANDLE$free).invokeExact(rawMS); + } catch (Throwable e) { + throw new RuntimeException("Failed to free memory", e); + } + } + + private static final FunctionDescriptor DESCRIPTOR$aligned_alloc = FunctionDescriptor.of( + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T + ); + + private static final FunctionDescriptor DESCRIPTOR$malloc = FunctionDescriptor.of( + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T + ); + + private static final FunctionDescriptor DESCRIPTOR$free = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS + ); + + private static final @Nullable MethodHandle HANDLE$aligned_alloc = RawFunctionLoader.link( + JavaSystemLibrary.INSTANCE.load("aligned_alloc"), + DESCRIPTOR$aligned_alloc + ); + private static final @Nullable MethodHandle HANDLE$malloc = RawFunctionLoader.link( + JavaSystemLibrary.INSTANCE.load("malloc"), + DESCRIPTOR$malloc + ); + private static final MethodHandle HANDLE$free = RawFunctionLoader.link( + JavaSystemLibrary.INSTANCE.load("free"), + DESCRIPTOR$free + ); +} diff --git a/src/club/doki7/ffm/Loader.java b/src/club/doki7/ffm/Loader.java new file mode 100644 index 0000000..85837b9 --- /dev/null +++ b/src/club/doki7/ffm/Loader.java @@ -0,0 +1,46 @@ +package club.doki7.ffm; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.*; +import java.lang.invoke.MethodHandle; + +@Deprecated(forRemoval = true, since = "0.2.4") +public final class Loader { + private static final Linker nativeLinker = Linker.nativeLinker(); + private static final SymbolLookup stdlibLookup = nativeLinker.defaultLookup(); + private static final SymbolLookup loaderLookup = SymbolLookup.loaderLookup(); + + @Deprecated(forRemoval = true, since = "0.2.4") + public static @NotNull MethodHandle loadFunction(String name, FunctionDescriptor descriptor) { + return loaderLookup.find(name) + .or(() -> stdlibLookup.find(name)) + .map(segment -> RawFunctionLoader.link(segment, descriptor)) + .orElseThrow(() -> new RuntimeException("native function " + name + " not found")); + } + + @Deprecated(forRemoval = true, since = "0.2.4") + public static @Nullable MethodHandle loadFunctionOrNull(String name, FunctionDescriptor descriptor) { + return loaderLookup.find(name) + .or(() -> stdlibLookup.find(name)) + .map(segment -> RawFunctionLoader.link(segment, descriptor)) + .orElse(null); + } + + @Deprecated(forRemoval = true, since = "0.2.4") + public static @NotNull MemorySegment loadFunction(String name) { + return loaderLookup.find(name) + .or(() -> stdlibLookup.find(name)) + .orElseThrow(() -> new RuntimeException("native function " + name + " not found")); + } + + @Deprecated(forRemoval = true, since = "0.2.4") + public static @Nullable MemorySegment loadFunctionOrNull(String name) { + return loaderLookup.find(name) + .or(() -> stdlibLookup.find(name)) + .orElse(null); + } + + private Loader() {} +} diff --git a/src/club/doki7/ffm/NativeLayout.java b/src/club/doki7/ffm/NativeLayout.java new file mode 100644 index 0000000..fed76bf --- /dev/null +++ b/src/club/doki7/ffm/NativeLayout.java @@ -0,0 +1,161 @@ +package club.doki7.ffm; + +import club.doki7.ffm.annotation.Unsigned; +import org.jetbrains.annotations.NotNull; + +import java.lang.foreign.*; +import java.util.ArrayList; +import java.util.List; + +public final class NativeLayout { + /// Memory layout of current JVM platform C {@code size_t} type. + /// + /// Currently, this field is set to {@link ValueLayout#ADDRESS}, whose JavaDoc claims that it + /// has the same size and alignment with a C {@code size_t} type. + public static final @NotNull ValueLayout C_SIZE_T = ValueLayout.ADDRESS; + public static final int POINTER_SIZE = (int) C_SIZE_T.byteSize(); + + /// Memory layout of current JVM platform C {@code long} type. + /// + /// Currently, all 32bit platforms will use {@link ValueLayout#JAVA_INT}. For 64bit platforms, + /// Windows will use {@link ValueLayout#JAVA_INT}, while other platforms will use + /// {@link ValueLayout#JAVA_LONG}. + /// + /// The detection algorithm came from LWJGL3. + /// @see lwjgl/core/src/main/java/org/lwgjl/system/Pointer.java + public static final @NotNull ValueLayout C_LONG; + public static final int C_LONG_SIZE; + + /// Memory layout of current JVM platform C {@code wchar_t} type. + /// + /// Currently, on Windows it is {@link ValueLayout#JAVA_SHORT} (2 bytes), while on other + /// platforms it is {@link ValueLayout#JAVA_INT} (4 bytes). + public static final @NotNull ValueLayout WCHAR_T; + public static final int WCHAR_SIZE; + + public static final @Unsigned int UINT32_MAX = (~0); + public static final @Unsigned long UINT64_MAX = (~0L); + + // FIXME: move this to somewhere else + private static boolean isWindows() { + return System.getProperty("os.name").toLowerCase().contains("windows"); + } + + static { + if (POINTER_SIZE == 4) { + // On typical 32bit platforms, long is 4 bytes + C_LONG = ValueLayout.JAVA_INT; + } + else if (POINTER_SIZE == 8) { + if (isWindows()) { + // On 64bit Windows, long is 4 bytes + C_LONG = ValueLayout.JAVA_INT; + } else { + // Otherwise, long is 8 bytes + C_LONG = ValueLayout.JAVA_LONG; + } + } + else { + throw new RuntimeException(String.format("unsupported pointer size: %d", POINTER_SIZE)); + } + + C_LONG_SIZE = (int) C_LONG.byteSize(); + + WCHAR_T = isWindows() + ? ValueLayout.JAVA_SHORT + : ValueLayout.JAVA_INT; + WCHAR_SIZE = (int) WCHAR_T.byteSize(); + } + + public static long readCLong(@NotNull MemorySegment segment, long offset) { + if (C_LONG == ValueLayout.JAVA_INT) { + return segment.get(ValueLayout.JAVA_INT, offset); + } else { + return segment.get(ValueLayout.JAVA_LONG, offset); + } + } + + public static void writeCLong(@NotNull MemorySegment segment, long offset, long value) { + if (C_LONG == ValueLayout.JAVA_INT) { + segment.set(ValueLayout.JAVA_INT, offset, (int) value); + } else { + segment.set(ValueLayout.JAVA_LONG, offset, value); + } + } + + public static @Unsigned long readCSizeT(@NotNull MemorySegment segment, long offset) { + if (C_SIZE_T == ValueLayout.JAVA_INT) { + return segment.get(ValueLayout.JAVA_INT, offset); + } else { + return segment.get(ValueLayout.JAVA_LONG, offset); + } + } + + public static void writeCSizeT(@NotNull MemorySegment segment, long offset, @Unsigned long value) { + if (C_SIZE_T == ValueLayout.JAVA_INT) { + segment.set(ValueLayout.JAVA_INT, offset, (int) value); + } else { + segment.set(ValueLayout.JAVA_LONG, offset, value); + } + } + + public static @Unsigned int readWCharT(@NotNull MemorySegment segment, long offset) { + if (WCHAR_T == ValueLayout.JAVA_INT) { + return segment.get(ValueLayout.JAVA_INT, offset); + } else { + return segment.get(ValueLayout.JAVA_SHORT, offset); + } + } + + public static void writeWCharT(@NotNull MemorySegment segment, long offset, int value) { + if (WCHAR_T == ValueLayout.JAVA_INT) { + segment.set(ValueLayout.JAVA_INT, offset, value); + } else { + segment.set(ValueLayout.JAVA_SHORT, offset, (short) value); + } + } + + /// Unlike {@link MemoryLayout#structLayout MemoryLayout.structLayout}, this function will + /// automatically compute and add padding to the layout to ensure that each element is properly + /// aligned. The resulting layout should be the same with a C struct layout. + /// + /// @param elements the elements of the struct + /// @return the struct layout + public static @NotNull StructLayout structLayout(@NotNull MemoryLayout... elements) { + long currentSize = 0; + long maxAlignment = 0; + List paddedElements = new ArrayList<>(); + + for (MemoryLayout element : elements) { + long alignment = element.byteAlignment(); + if (alignment > maxAlignment) { + maxAlignment = alignment; + } + long padding = (alignment - (currentSize % alignment)) % alignment; + if (padding != 0) { + paddedElements.add(MemoryLayout.paddingLayout(padding)); + currentSize += padding; + } + + paddedElements.add(element); + currentSize += element.byteSize(); + } + + if (maxAlignment != 0) { + long padding = (maxAlignment - (currentSize % maxAlignment)) % maxAlignment; + if (padding != 0) { + paddedElements.add(MemoryLayout.paddingLayout(padding)); + } + } + + MemoryLayout[] paddedElementsArray = paddedElements.toArray(new MemoryLayout[0]); + return MemoryLayout.structLayout(paddedElementsArray); + } + + /// Currently forwards to {@link MemoryLayout#unionLayout}. + public static @NotNull UnionLayout unionLayout(@NotNull MemoryLayout... elements) { + return MemoryLayout.unionLayout(elements); + } + + private NativeLayout() {} +} diff --git a/src/club/doki7/ffm/RawFunctionLoader.java b/src/club/doki7/ffm/RawFunctionLoader.java new file mode 100644 index 0000000..71c68ed --- /dev/null +++ b/src/club/doki7/ffm/RawFunctionLoader.java @@ -0,0 +1,41 @@ +package club.doki7.ffm; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.lang.foreign.MemorySegment; +import java.lang.invoke.MethodHandle; +import java.nio.file.LinkOption; + +@FunctionalInterface +public interface RawFunctionLoader { + @NotNull MemorySegment apply(@NotNull String name); + + default @NotNull MemorySegment load(@NotNull String name) { + return apply(name); + } + + Linker nativeLinker = Linker.nativeLinker(); + + static @Nullable MethodHandle link(@NotNull MemorySegment segment, FunctionDescriptor descriptor) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + return nativeLinker.downcallHandle(segment, descriptor); + } + + static @Nullable MethodHandle linkWithOptions( + @NotNull MemorySegment segment, + FunctionDescriptor descriptor, + Linker.Option ...options + ) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + return nativeLinker.downcallHandle(segment, descriptor, options); + } +} diff --git a/src/club/doki7/ffm/annotation/Bitmask.java b/src/club/doki7/ffm/annotation/Bitmask.java new file mode 100644 index 0000000..f99c59b --- /dev/null +++ b/src/club/doki7/ffm/annotation/Bitmask.java @@ -0,0 +1,9 @@ +package club.doki7.ffm.annotation; + +import java.lang.annotation.Documented; + +/// Marker annotation, indicating that an integral value is a C bitmask type. +@Documented +public @interface Bitmask { + Class value() default void.class; +} diff --git a/src/club/doki7/ffm/annotation/EnumType.java b/src/club/doki7/ffm/annotation/EnumType.java new file mode 100644 index 0000000..567c93c --- /dev/null +++ b/src/club/doki7/ffm/annotation/EnumType.java @@ -0,0 +1,9 @@ +package club.doki7.ffm.annotation; + +import java.lang.annotation.Documented; + +/// Marker annotation, indicating that an integral value is a C enumeration type. +@Documented +public @interface EnumType { + Class value() default void.class; +} diff --git a/src/club/doki7/ffm/annotation/NativeType.java b/src/club/doki7/ffm/annotation/NativeType.java new file mode 100644 index 0000000..e87cefb --- /dev/null +++ b/src/club/doki7/ffm/annotation/NativeType.java @@ -0,0 +1,9 @@ +package club.doki7.ffm.annotation; + +import java.lang.annotation.Documented; + +/// Marker annotation, indicating that a value is actually of an aliased native type. +@Documented +public @interface NativeType { + String value() default ""; +} diff --git a/src/club/doki7/ffm/annotation/Pointer.java b/src/club/doki7/ffm/annotation/Pointer.java new file mode 100644 index 0000000..34bc4bb --- /dev/null +++ b/src/club/doki7/ffm/annotation/Pointer.java @@ -0,0 +1,11 @@ +package club.doki7.ffm.annotation; + +import java.lang.annotation.Documented; + +/// Marker annotation, indicating that a pointer value ({@link java.lang.foreign.MemorySegment} or +/// {@code long}) is a pointer to a specific type. +@Documented +public @interface Pointer { + Class target() default Object.class; + String comment() default ""; +} diff --git a/src/club/doki7/ffm/annotation/Unsafe.java b/src/club/doki7/ffm/annotation/Unsafe.java new file mode 100644 index 0000000..699d0b9 --- /dev/null +++ b/src/club/doki7/ffm/annotation/Unsafe.java @@ -0,0 +1,11 @@ +package club.doki7.ffm.annotation; + +import java.lang.annotation.Documented; + +/// Marker annotation, indicating that the annotated method is Unsafe. +/// +/// An {@link Unsafe} method, if misused, could cause undefined behaviour such as buffer overflow or +/// null pointer dereference, which could in turn cause data corruption or even crash the JVM. +@Documented +public @interface Unsafe { +} diff --git a/src/club/doki7/ffm/annotation/UnsafeConstructor.java b/src/club/doki7/ffm/annotation/UnsafeConstructor.java new file mode 100644 index 0000000..b4721d3 --- /dev/null +++ b/src/club/doki7/ffm/annotation/UnsafeConstructor.java @@ -0,0 +1,12 @@ +package club.doki7.ffm.annotation; + +import java.lang.annotation.Documented; + +/// Marker annotation, indicating that the annotated record constructor is Unsafe +/// +/// An {@link UnsafeConstructor} constructor, if misused, could cause undefined behaviour such as +/// buffer overflow or null pointer dereference, which could in turn cause data corruption or even +/// crash the JVM. +@Documented +public @interface UnsafeConstructor { +} diff --git a/src/club/doki7/ffm/annotation/Unsigned.java b/src/club/doki7/ffm/annotation/Unsigned.java new file mode 100644 index 0000000..83cc7e5 --- /dev/null +++ b/src/club/doki7/ffm/annotation/Unsigned.java @@ -0,0 +1,10 @@ +package club.doki7.ffm.annotation; + +import java.lang.annotation.Documented; + +/// Marker annotation, indicating that the annotated integral value should be treated as Unsigned. +/// +/// For example, if an {@code int} is annotated with this annotation, you should use +/// {@link Integer#toUnsignedString} to get its string representation, and so on. +@Documented +public @interface Unsigned {} diff --git a/src/club/doki7/ffm/annotation/ValueBasedCandidate.java b/src/club/doki7/ffm/annotation/ValueBasedCandidate.java new file mode 100644 index 0000000..9bb3cb8 --- /dev/null +++ b/src/club/doki7/ffm/annotation/ValueBasedCandidate.java @@ -0,0 +1,12 @@ +package club.doki7.ffm.annotation; + +import java.lang.annotation.Documented; + +/// Marker annotation, indicating the annotated type will consequentially become {@code @ValueBased} +/// once Project Valhalla gets stabilized. +/// +/// In order to maintain compatibility, it's better not to rely on object hash identity of these +/// annotated types. +@Documented +public @interface ValueBasedCandidate { +} diff --git a/src/club/doki7/ffm/annotation/package-info.java b/src/club/doki7/ffm/annotation/package-info.java new file mode 100644 index 0000000..551b11e --- /dev/null +++ b/src/club/doki7/ffm/annotation/package-info.java @@ -0,0 +1,2 @@ +/// Auxiliary annotation. +package club.doki7.ffm.annotation; diff --git a/src/club/doki7/ffm/bits/BitfieldUtil.java b/src/club/doki7/ffm/bits/BitfieldUtil.java new file mode 100644 index 0000000..87b402c --- /dev/null +++ b/src/club/doki7/ffm/bits/BitfieldUtil.java @@ -0,0 +1,202 @@ +package club.doki7.ffm.bits; + +import club.doki7.ffm.annotation.Unsigned; +import org.jetbrains.annotations.NotNull; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.MemorySegment; +import java.nio.ByteOrder; + +public final class BitfieldUtil { + public static @Unsigned boolean readBit( + @NotNull MemorySegment segment, + @Unsigned int bit + ) { + return switch ((int) segment.byteSize()) { + case 1 -> readBit(segment.get(AddressLayout.JAVA_BYTE, 0), bit); + case 2 -> readBit(segment.get(AddressLayout.JAVA_SHORT, 0), bit); + case 4 -> readBit(segment.get(AddressLayout.JAVA_INT, 0), bit); + default -> throw new IllegalArgumentException("Unsupported size: " + segment.byteSize()); + }; + } + + public static @Unsigned int readBits( + @NotNull MemorySegment segment, + @Unsigned int startBit, + @Unsigned int endBit + ) { + return switch ((int) segment.byteSize()) { + case 1 -> readBits(segment.get(AddressLayout.JAVA_BYTE, 0), startBit, endBit); + case 2 -> readBits(segment.get(AddressLayout.JAVA_SHORT, 0), startBit, endBit); + case 4 -> readBits(segment.get(AddressLayout.JAVA_INT, 0), startBit, endBit); + default -> throw new IllegalArgumentException("Unsupported size: " + segment.byteSize()); + }; + } + + public static void writeBit( + @NotNull MemorySegment segment, + @Unsigned int bit, + boolean bitValue + ) { + switch ((int) segment.byteSize()) { + case 1 -> segment.set(AddressLayout.JAVA_BYTE, 0, writeBit(segment.get(AddressLayout.JAVA_BYTE, 0), bit, bitValue)); + case 2 -> segment.set(AddressLayout.JAVA_SHORT, 0, writeBit(segment.get(AddressLayout.JAVA_SHORT, 0), bit, bitValue)); + case 4 -> segment.set(AddressLayout.JAVA_INT, 0, writeBit(segment.get(AddressLayout.JAVA_INT, 0), bit, bitValue)); + default -> throw new IllegalArgumentException("Unsupported size: " + segment.byteSize()); + } + } + + public static void writeBits( + @NotNull MemorySegment segment, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned int bits + ) { + switch ((int) segment.byteSize()) { + case 1 -> segment.set(AddressLayout.JAVA_BYTE, 0, writeBits(segment.get(AddressLayout.JAVA_BYTE, 0), startBit, endBit, (byte) bits)); + case 2 -> segment.set(AddressLayout.JAVA_SHORT, 0, writeBits(segment.get(AddressLayout.JAVA_SHORT, 0), startBit, endBit, (short) bits)); + case 4 -> segment.set(AddressLayout.JAVA_INT, 0, writeBits(segment.get(AddressLayout.JAVA_INT, 0), startBit, endBit, bits)); + default -> throw new IllegalArgumentException("Unsupported size: " + segment.byteSize()); + } + } + + public static boolean readBit( + @Unsigned byte value, + @Unsigned int bit + ) { + checkBitRange(bit, Byte.SIZE); + return impl.readBitUnchecked(value, bit); + } + + public static boolean readBit( + @Unsigned short value, + @Unsigned int bit + ) { + checkBitRange(bit, Short.SIZE); + return impl.readBitUnchecked(value, bit); + } + + public static boolean readBit( + @Unsigned int value, + @Unsigned int bit + ) { + checkBitRange(bit, Integer.SIZE); + return impl.readBitUnchecked(value, bit); + } + + public static @Unsigned byte readBits( + @Unsigned byte value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + checkBitRange(startBit, endBit, Byte.SIZE); + return impl.readBitsUnchecked(value, startBit, endBit); + } + + public static @Unsigned short readBits( + @Unsigned short value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + checkBitRange(startBit, endBit, Short.SIZE); + return impl.readBitsUnchecked(value, startBit, endBit); + } + + public static @Unsigned int readBits( + @Unsigned int value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + checkBitRange(startBit, endBit, Integer.SIZE); + return impl.readBitsUnchecked(value, startBit, endBit); + } + + public static @Unsigned byte writeBit( + @Unsigned byte value, + @Unsigned int bit, + boolean bitValue + ) { + checkBitRange(bit, Byte.SIZE); + return impl.writeBitUnchecked(value, bit, bitValue); + } + + public static @Unsigned short writeBit( + @Unsigned short value, + @Unsigned int bit, + boolean bitValue + ) { + checkBitRange(bit, Short.SIZE); + return impl.writeBitUnchecked(value, bit, bitValue); + } + + public static @Unsigned int writeBit( + @Unsigned int value, + @Unsigned int bit, + boolean bitValue + ) { + checkBitRange(bit, Integer.SIZE); + return impl.writeBitUnchecked(value, bit, bitValue); + } + + public static @Unsigned byte writeBits( + @Unsigned byte value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned byte bits + ) { + checkBitRange(startBit, endBit, Byte.SIZE); + return impl.writeBitsUnchecked(value, startBit, endBit, bits); + } + + public static @Unsigned short writeBits( + @Unsigned short value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned short bits + ) { + checkBitRange(startBit, endBit, Short.SIZE); + return impl.writeBitsUnchecked(value, startBit, endBit, bits); + } + + public static @Unsigned int writeBits( + @Unsigned int value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned int bits + ) { + checkBitRange(startBit, endBit, Integer.SIZE); + return impl.writeBitsUnchecked(value, startBit, endBit, bits); + } + + private static void checkBitRange(int bit, int size) { + if (bit < 0 || bit >= size) { + throw new IllegalArgumentException("bit must be no less than 0 and less than " + size); + } + } + + private static void checkBitRange(int startBit, int endBit, int size) { + if (startBit < 0 || endBit > size) { + throw new IllegalArgumentException("startBit must be no less than 0 and endBit must be no more than " + size); + } + if (startBit >= endBit) { + throw new IllegalArgumentException("startBit must be less than endBit"); + } + } + + private static final @NotNull IBitfieldUtilImpl impl; + static { + // On most platforms, the bitfields are packed from right to left. However, on ARM platform, + // the bitfields packing depends on the endianness. + String arch = System.getProperty("os.arch").toLowerCase(); + if (arch.contains("arm") || arch.contains("aarch")) { + if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { + impl = new BitfieldUtilImplL2R(); + } else { + impl = new BitfieldUtilImplR2L(); + } + } else { + // May need future refinement, but adequate for now. + impl = new BitfieldUtilImplR2L(); + } + } +} diff --git a/src/club/doki7/ffm/bits/BitfieldUtilImplL2R.java b/src/club/doki7/ffm/bits/BitfieldUtilImplL2R.java new file mode 100644 index 0000000..3f0bb31 --- /dev/null +++ b/src/club/doki7/ffm/bits/BitfieldUtilImplL2R.java @@ -0,0 +1,158 @@ +package club.doki7.ffm.bits; + +import club.doki7.ffm.annotation.Unsigned; + +/// On certain platforms, bitfields are packed from left to right. +/// +/// For example, for the following +/// C struct: +/// +/// {@snippet lang=c : +/// typedef struct { +/// uint8_t r : 3; // startBit = 0, endBit = 3 +/// uint8_t g : 3; // startBit = 3, endBit = 6 +/// uint8_t b : 2; // startBit = 6, endBit = 8 +/// } rgb332_t; +/// } +/// +/// The bitfield is packed as such: +/// +/// {@snippet : +/// bit 765 432 10 +/// value RRR GGG BB +/// } +/// +/// So to read the {@code G} field, we need to shift the value right by 2 ({@code = 8 - endBit}) +/// bits and mask it with 0x07 ({@code = (1 << (endBit - startBit)) - 1}). +final class BitfieldUtilImplL2R implements IBitfieldUtilImpl { + @Override + public boolean readBitUnchecked(@Unsigned byte value, @Unsigned int bit) { + return ((value >>> (Byte.SIZE - bit - 1)) & 0x01) != 0; + } + + @Override + public boolean readBitUnchecked(@Unsigned short value, @Unsigned int bit) { + return ((value >>> (Short.SIZE - bit - 1)) & 0x01) != 0; + } + + @Override + public boolean readBitUnchecked(@Unsigned int value, @Unsigned int bit) { + return ((value >>> (Integer.SIZE - bit - 1)) & 0x01) != 0; + } + + @Override + public @Unsigned byte readBitsUnchecked( + @Unsigned byte value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + int shiftRight = Byte.SIZE - endBit; + int mask = (1 << (endBit - startBit)) - 1; + return (byte) ((value >>> shiftRight) & mask); + } + + @Override + public @Unsigned short readBitsUnchecked( + @Unsigned short value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + int shiftRight = Short.SIZE - endBit; + int mask = (1 << (endBit - startBit)) - 1; + return (short) ((value >>> shiftRight) & mask); + } + + @Override + public int readBitsUnchecked( + @Unsigned int value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + int shiftRight = Integer.SIZE - endBit; + long mask = (1L << (endBit - startBit)) - 1; + return (int) ((value >>> shiftRight) & mask); + } + + @Override + public @Unsigned byte writeBitUnchecked( + @Unsigned byte value, + @Unsigned int bit, + boolean bitValue + ) { + if (bitValue) { + return (byte) (value | (1 << (Byte.SIZE - bit - 1))); + } else { + return (byte) (value & ~(1 << (Byte.SIZE - bit - 1))); + } + } + + @Override + public @Unsigned short writeBitUnchecked( + @Unsigned short value, + @Unsigned int bit, + boolean bitValue + ) { + if (bitValue) { + return (short) (value | (1 << (Short.SIZE - bit - 1))); + } else { + return (short) (value & ~(1 << (Short.SIZE - bit - 1))); + } + } + + @Override + public @Unsigned int writeBitUnchecked( + @Unsigned int value, + @Unsigned int bit, + boolean bitValue + ) { + if (bitValue) { + return (value | (1 << (Integer.SIZE - bit - 1))); + } else { + return (value & ~(1 << (Integer.SIZE - bit - 1))); + } + } + + @Override + public @Unsigned byte writeBitsUnchecked( + @Unsigned byte value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned byte bits + ) { + int shiftLeft = Byte.SIZE - endBit; + int mask = (1 << (endBit - startBit)) - 1; + int maskShifted = mask << shiftLeft; + int bitsShifted = (bits & mask) << shiftLeft; + return (byte) ((value & ~maskShifted) | bitsShifted); + } + + @Override + public @Unsigned short writeBitsUnchecked( + @Unsigned short value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned short bits + ) { + int shiftLeft = Short.SIZE - endBit; + int mask = (1 << (endBit - startBit)) - 1; + int maskShifted = mask << shiftLeft; + int bitsShifted = (bits & mask) << shiftLeft; + return (short) ((value & ~maskShifted) | bitsShifted); + } + + @Override + public @Unsigned int writeBitsUnchecked( + @Unsigned int value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned int bits + ) { + int shiftLeft = Integer.SIZE - endBit; + long mask = (1L << (endBit - startBit)) - 1; + long maskShifted = mask << shiftLeft; + long bitsShifted = (bits & mask) << shiftLeft; + return (int) ((value & ~maskShifted) | bitsShifted); + } + + BitfieldUtilImplL2R() {} +} diff --git a/src/club/doki7/ffm/bits/BitfieldUtilImplR2L.java b/src/club/doki7/ffm/bits/BitfieldUtilImplR2L.java new file mode 100644 index 0000000..a0c1ec9 --- /dev/null +++ b/src/club/doki7/ffm/bits/BitfieldUtilImplR2L.java @@ -0,0 +1,152 @@ +package club.doki7.ffm.bits; + +import club.doki7.ffm.annotation.Unsigned; + +/// On certain platforms, bitfields are packed from right to left. +/// +/// For example, for the following +/// C struct: +/// +/// {@snippet lang=c : +/// typedef struct { +/// uint8_t r : 3; // startBit = 0, endBit = 3 +/// uint8_t g : 3; // startBit = 3, endBit = 6 +/// uint8_t b : 2; // startBit = 6, endBit = 8 +/// } rgb332_t; +/// } +/// +/// The bitfield is packed as such: +/// +/// {@snippet : +/// bit 76 543 210 +/// value BB GGG RRR +/// } +/// +/// So to read the {@code G} field, we need to shift the value right by 3 ({@code = startBit}) bits +/// and mask it with 0x07 ({@code = (1 << (endBit - startBit)) - 1}). +final class BitfieldUtilImplR2L implements IBitfieldUtilImpl { + @Override + public @Unsigned boolean readBitUnchecked(@Unsigned byte value, @Unsigned int bit) { + return ((value >>> bit) & 0x01) != 0; + } + + @Override + public @Unsigned boolean readBitUnchecked(@Unsigned short value, @Unsigned int bit) { + return ((value >>> bit) & 0x01) != 0; + } + + @Override + public @Unsigned boolean readBitUnchecked(@Unsigned int value, @Unsigned int bit) { + return ((value >>> bit) & 0x01) != 0; + } + + @Override + public @Unsigned byte readBitsUnchecked( + @Unsigned byte value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + int mask = (1 << (endBit - startBit)) - 1; + return (byte) ((value >>> startBit) & mask); + } + + @Override + public @Unsigned short readBitsUnchecked( + @Unsigned short value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + int mask = (1 << (endBit - startBit)) - 1; + return (short) ((value >>> startBit) & mask); + } + + @Override + public @Unsigned int readBitsUnchecked( + @Unsigned int value, + @Unsigned int startBit, + @Unsigned int endBit + ) { + long mask = (1L << (endBit - startBit)) - 1; + return (int) ((value >>> startBit) & mask); + } + + @Override + public @Unsigned byte writeBitUnchecked( + @Unsigned byte value, + @Unsigned int bit, + boolean bitValue + ) { + if (bitValue) { + return (byte) (value | (1 << bit)); + } else { + return (byte) (value & ~(1 << bit)); + } + } + + @Override + public @Unsigned short writeBitUnchecked( + @Unsigned short value, + @Unsigned int bit, + boolean bitValue + ) { + if (bitValue) { + return (short) (value | (1 << bit)); + } else { + return (short) (value & ~(1 << bit)); + } + } + + @Override + public @Unsigned int writeBitUnchecked( + @Unsigned int value, + @Unsigned int bit, + boolean bitValue + ) { + if (bitValue) { + return value | (1 << bit); + } else { + return value & ~(1 << bit); + } + } + + @Override + public @Unsigned byte writeBitsUnchecked( + @Unsigned byte value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned byte bits + ) { + int mask = (1 << (endBit - startBit)) - 1; + int maskShifted = mask << startBit; + int bitsShifted = (bits & mask) << startBit; + return (byte) ((value & ~maskShifted) | bitsShifted); + } + + @Override + public @Unsigned short writeBitsUnchecked( + @Unsigned short value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned short bits + ) { + int mask = (1 << (endBit - startBit)) - 1; + int maskShifted = mask << startBit; + int bitsShifted = (bits & mask) << startBit; + return (short) ((value & ~maskShifted) | bitsShifted); + } + + @Override + public @Unsigned int writeBitsUnchecked( + @Unsigned int value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned int bits + ) { + long mask = (1L << (endBit - startBit)) - 1; + long maskShifted = mask << startBit; + long bitsShifted = (bits & mask) << startBit; + return (int) ((value & ~maskShifted) | bitsShifted); + } + + BitfieldUtilImplR2L() {} +} diff --git a/src/club/doki7/ffm/bits/IBitfieldUtilImpl.java b/src/club/doki7/ffm/bits/IBitfieldUtilImpl.java new file mode 100644 index 0000000..0acad05 --- /dev/null +++ b/src/club/doki7/ffm/bits/IBitfieldUtilImpl.java @@ -0,0 +1,45 @@ +package club.doki7.ffm.bits; + +import club.doki7.ffm.annotation.Unsigned; + +sealed interface IBitfieldUtilImpl permits BitfieldUtilImplL2R, BitfieldUtilImplR2L { + boolean readBitUnchecked(@Unsigned byte value, @Unsigned int bit); + boolean readBitUnchecked(@Unsigned short value, @Unsigned int bit); + boolean readBitUnchecked(@Unsigned int value, @Unsigned int bit); + + @Unsigned + byte readBitsUnchecked(@Unsigned byte value, @Unsigned int startBit, @Unsigned int endBit); + @Unsigned + short readBitsUnchecked(@Unsigned short value, @Unsigned int startBit, @Unsigned int endBit); + @Unsigned + int readBitsUnchecked(@Unsigned int value, @Unsigned int startBit, @Unsigned int endBit); + + @Unsigned + byte writeBitUnchecked(@Unsigned byte value, @Unsigned int bit, boolean bitValue); + @Unsigned + short writeBitUnchecked(@Unsigned short value, @Unsigned int bit, boolean bitValue); + @Unsigned + int writeBitUnchecked(@Unsigned int value, @Unsigned int bit, boolean bitValue); + + @Unsigned + byte writeBitsUnchecked( + @Unsigned byte value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned byte bits + ); + @Unsigned + short writeBitsUnchecked( + @Unsigned short value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned short bits + ); + @Unsigned + int writeBitsUnchecked( + @Unsigned int value, + @Unsigned int startBit, + @Unsigned int endBit, + @Unsigned int bits + ); +} diff --git a/src/club/doki7/ffm/bits/package-info.java b/src/club/doki7/ffm/bits/package-info.java new file mode 100644 index 0000000..7f38e16 --- /dev/null +++ b/src/club/doki7/ffm/bits/package-info.java @@ -0,0 +1,2 @@ +/// Cross-platform binary bit manipulation utilities. +package club.doki7.ffm.bits; diff --git a/src/club/doki7/ffm/library/ILibraryLoader.java b/src/club/doki7/ffm/library/ILibraryLoader.java new file mode 100644 index 0000000..54719c9 --- /dev/null +++ b/src/club/doki7/ffm/library/ILibraryLoader.java @@ -0,0 +1,20 @@ +package club.doki7.ffm.library; + +import org.jetbrains.annotations.NotNull; + +public sealed interface ILibraryLoader permits + WindowsLibraryLoader, + UnixLibraryLoader, + JavaSystemLibraryLoader +{ + @NotNull ISharedLibrary loadLibrary(@NotNull String libName) throws UnsatisfiedLinkError; + + static ILibraryLoader platformLoader() { + String osName = System.getProperty("os.name").toLowerCase(); + if (osName.contains("windows")) { + return WindowsLibraryLoader.INSTANCE; + } else { + return UnixLibraryLoader.INSTANCE; + } + } +} diff --git a/src/club/doki7/ffm/library/ISharedLibrary.java b/src/club/doki7/ffm/library/ISharedLibrary.java new file mode 100644 index 0000000..d6a0619 --- /dev/null +++ b/src/club/doki7/ffm/library/ISharedLibrary.java @@ -0,0 +1,11 @@ +package club.doki7.ffm.library; + +import club.doki7.ffm.RawFunctionLoader; + +public sealed interface ISharedLibrary extends RawFunctionLoader, AutoCloseable permits + JavaSystemLibrary, + UnixLibrary, + WindowsLibrary +{ + @Override void close(); +} diff --git a/src/club/doki7/ffm/library/JavaSystemLibrary.java b/src/club/doki7/ffm/library/JavaSystemLibrary.java new file mode 100644 index 0000000..7024bdf --- /dev/null +++ b/src/club/doki7/ffm/library/JavaSystemLibrary.java @@ -0,0 +1,25 @@ +package club.doki7.ffm.library; + +import org.jetbrains.annotations.NotNull; + +import java.lang.foreign.Linker; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SymbolLookup; + +public enum JavaSystemLibrary implements ISharedLibrary { + INSTANCE; + + @Override + public @NotNull MemorySegment apply(@NotNull String name) { + return loaderLookup.find(name) + .or(() -> stdlibLookup.find(name)) + .orElse(MemorySegment.NULL); + } + + @Override + public void close() {} + + private static final Linker nativeLinker = Linker.nativeLinker(); + private static final SymbolLookup stdlibLookup = nativeLinker.defaultLookup(); + private static final SymbolLookup loaderLookup = SymbolLookup.loaderLookup(); +} diff --git a/src/club/doki7/ffm/library/JavaSystemLibraryLoader.java b/src/club/doki7/ffm/library/JavaSystemLibraryLoader.java new file mode 100644 index 0000000..239ee41 --- /dev/null +++ b/src/club/doki7/ffm/library/JavaSystemLibraryLoader.java @@ -0,0 +1,17 @@ +package club.doki7.ffm.library; + +import org.jetbrains.annotations.NotNull; + +public enum JavaSystemLibraryLoader implements ILibraryLoader { + INSTANCE; + + @Override + public @NotNull ISharedLibrary loadLibrary(@NotNull String libName) throws UnsatisfiedLinkError { + try { + System.loadLibrary(libName); + } catch (Throwable e) { + System.load(libName); + } + return JavaSystemLibrary.INSTANCE; + } +} diff --git a/src/club/doki7/ffm/library/UnixLibrary.java b/src/club/doki7/ffm/library/UnixLibrary.java new file mode 100644 index 0000000..6848dda --- /dev/null +++ b/src/club/doki7/ffm/library/UnixLibrary.java @@ -0,0 +1,60 @@ +package club.doki7.ffm.library; + +import club.doki7.ffm.RawFunctionLoader; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.util.Objects; + +public final class UnixLibrary implements ISharedLibrary { + @Override + public @NotNull MemorySegment apply(@NotNull String libName) throws UnsatisfiedLinkError { + try (Arena arena = Arena.ofConfined()){ + MethodHandle h = Objects.requireNonNull(hDlsym); + MemorySegment nameSegment = arena.allocateFrom(libName); + return (MemorySegment) h.invokeExact(library, nameSegment); + } catch (Throwable e) { + throw new UnsatisfiedLinkError("Failed to load symbol '" + libName + "': " + e.getMessage()); + } + } + + @Override + public void close() { + try { + MethodHandle h = Objects.requireNonNull(hDlclose); + h.invokeExact(library); + } catch (Throwable a) {} + } + + UnixLibrary(MemorySegment library) { + this.library = library; + } + + private final MemorySegment library; + + private static final FunctionDescriptor DESCRIPTOR$dlsym = + FunctionDescriptor.of( + ValueLayout.ADDRESS, // returns void* + ValueLayout.ADDRESS, // void *handle + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE) // const char *symbol + ); + private static final FunctionDescriptor DESCRIPTOR$dlclose = + FunctionDescriptor.of( + ValueLayout.JAVA_INT, // returns int + ValueLayout.ADDRESS // void *handle + ); + private static final @Nullable MethodHandle hDlsym; + private static final @Nullable MethodHandle hDlclose; + + static { + MemorySegment pfnDlsym = JavaSystemLibrary.INSTANCE.load("dlsym"); + MemorySegment pfnDlclose = JavaSystemLibrary.INSTANCE.load("dlclose"); + hDlsym = RawFunctionLoader.link(pfnDlsym, DESCRIPTOR$dlsym); + hDlclose = RawFunctionLoader.link(pfnDlclose, DESCRIPTOR$dlclose); + } +} diff --git a/src/club/doki7/ffm/library/UnixLibraryLoader.java b/src/club/doki7/ffm/library/UnixLibraryLoader.java new file mode 100644 index 0000000..01fc641 --- /dev/null +++ b/src/club/doki7/ffm/library/UnixLibraryLoader.java @@ -0,0 +1,60 @@ +package club.doki7.ffm.library; + +import club.doki7.ffm.RawFunctionLoader; +import club.doki7.ffm.util.UnixUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.util.Objects; + +public enum UnixLibraryLoader implements ILibraryLoader { + INSTANCE; + + @Override + public @NotNull ISharedLibrary loadLibrary(@NotNull String libName) throws UnsatisfiedLinkError { + if (!libName.startsWith("/")) { + libName = "lib" + libName + ".so"; + } + + MemorySegment result; + try (Arena arena = Arena.ofConfined()) { + MethodHandle h = Objects.requireNonNull(hDlopen); + MemorySegment nameSegment = arena.allocateFrom(libName); + result = (MemorySegment) h.invokeExact(nameSegment, RTLD_LAZY | RTLD_LOCAL); + } catch (Throwable e) { + throw new UnsatisfiedLinkError(e.getMessage()); + } + + if (result.equals(MemorySegment.NULL)) { + String error = UnixUtil.dlerror(); + if (error != null) { + throw new UnsatisfiedLinkError("dlopen error: " + error); + } else { + throw new UnsatisfiedLinkError("dlopen error: unknown error"); + } + } + + return new UnixLibrary(result); + } + + private static final FunctionDescriptor DESCRIPTOR$dlopen = FunctionDescriptor.of( + ValueLayout.ADDRESS, // returns void* + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), // const char* filename + ValueLayout.JAVA_INT // int flag + ); + private static final @Nullable MethodHandle hDlopen; + static { + MemorySegment pfnDlopen = JavaSystemLibrary.INSTANCE.load("dlopen"); + hDlopen = RawFunctionLoader.link(pfnDlopen, DESCRIPTOR$dlopen); + + UnixUtil.forceLoad(); + } + + private static final int RTLD_LAZY = 0x1; + private static final int RTLD_LOCAL = 0; +} diff --git a/src/club/doki7/ffm/library/WindowsLibrary.java b/src/club/doki7/ffm/library/WindowsLibrary.java new file mode 100644 index 0000000..7c625b2 --- /dev/null +++ b/src/club/doki7/ffm/library/WindowsLibrary.java @@ -0,0 +1,58 @@ +package club.doki7.ffm.library; + +import club.doki7.ffm.RawFunctionLoader; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.util.Objects; + +public final class WindowsLibrary implements ISharedLibrary { + @Override + public @NotNull MemorySegment apply(@NotNull String name) { + try (Arena arena = Arena.ofConfined()){ + MethodHandle h = Objects.requireNonNull(hGetProcAddress); + return (MemorySegment) h.invokeExact(this.hModule, arena.allocateFrom(name)); + } catch (Throwable e) { + throw new UnsatisfiedLinkError(e.getMessage()); + } + } + + @Override + public void close() { + try { + MethodHandle h = Objects.requireNonNull(hFreeLibrary); + h.invokeExact(this.hModule); + } catch (Throwable a) {} + } + + WindowsLibrary(MemorySegment hModule) { + this.hModule = hModule; + } + + private final MemorySegment hModule; + + private static final FunctionDescriptor DESCRIPTOR$GetProcAddress = + FunctionDescriptor.of( + ValueLayout.ADDRESS, // returns FARPROC + ValueLayout.ADDRESS, // HMODULE hModule + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE) // LPCSTR lpProcName + ); + public static final FunctionDescriptor DESCRIPTOR$FreeLibrary = + FunctionDescriptor.of( + ValueLayout.JAVA_INT, // returns BOOL (Windows BOOL, i.e., int32) + ValueLayout.ADDRESS // HMODULE hLibModule + ); + private static final @Nullable MethodHandle hGetProcAddress; + private static final @Nullable MethodHandle hFreeLibrary; + static { + MemorySegment pfnGetProcAddress = JavaSystemLibrary.INSTANCE.load("GetProcAddress"); + MemorySegment pfnFreeLibrary = JavaSystemLibrary.INSTANCE.load("FreeLibrary"); + hGetProcAddress = RawFunctionLoader.link(pfnGetProcAddress, DESCRIPTOR$GetProcAddress); + hFreeLibrary = RawFunctionLoader.link(pfnFreeLibrary, DESCRIPTOR$FreeLibrary); + } +} diff --git a/src/club/doki7/ffm/library/WindowsLibraryLoader.java b/src/club/doki7/ffm/library/WindowsLibraryLoader.java new file mode 100644 index 0000000..0ea5bc3 --- /dev/null +++ b/src/club/doki7/ffm/library/WindowsLibraryLoader.java @@ -0,0 +1,74 @@ +package club.doki7.ffm.library; + +import club.doki7.ffm.RawFunctionLoader; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.*; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.VarHandle; +import java.util.Objects; + +public enum WindowsLibraryLoader implements ILibraryLoader { + INSTANCE; + + @Override + public @NotNull ISharedLibrary loadLibrary( + @NotNull String libName + ) throws UnsatisfiedLinkError { + try (Arena arena = Arena.ofConfined()) { + MethodHandle h = Objects.requireNonNull(hLoadLibraryW); + StructLayout captureStateLayout = Linker.Option.captureStateLayout(); + MemorySegment capturedState = arena.allocate(captureStateLayout); + + char[] charArray = libName.toCharArray(); + MemorySegment lpLibName = arena.allocate(ValueLayout.JAVA_SHORT, charArray.length + 1); + lpLibName.copyFrom(MemorySegment.ofArray(charArray)); + + MemorySegment result; + try { + result = (MemorySegment) h.invokeExact(capturedState, lpLibName); + } catch (Throwable e) { + throw new UnsatisfiedLinkError(e.getMessage()); + } + + if (result.equals(MemorySegment.NULL)) { + VarHandle vh = captureStateLayout.varHandle( + MemoryLayout.PathElement.groupElement("GetLastError") + ); + int lastError = (int) vh.get(capturedState, 0L); + if (lastError < 0) { + throw new UnsatisfiedLinkError("LoadLibraryW error: unknown error"); + } else { + throw new UnsatisfiedLinkError("LoadLibraryW error: " + lastError); + } + } + + return new WindowsLibrary(result); + } + } + + private static final FunctionDescriptor DESCRIPTOR$LoadLibraryW = FunctionDescriptor.of( + ValueLayout.ADDRESS, // returns HMODULE + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_SHORT) // LPCWSTR lpLibFileName + ); + private static final @Nullable MethodHandle hLoadLibraryW; + static { + if (System.getProperty("os.name").toLowerCase().contains("windows")) { + try { + System.loadLibrary("kernel32"); + } catch (Throwable e) { + throw new RuntimeException(e); + } + + MemorySegment pfnLoadLibraryW = JavaSystemLibrary.INSTANCE.load("LoadLibraryW"); + hLoadLibraryW = RawFunctionLoader.linkWithOptions( + pfnLoadLibraryW, + DESCRIPTOR$LoadLibraryW, + Linker.Option.captureCallState("GetLastError") + ); + } else { + hLoadLibraryW = null; + } + } +} diff --git a/src/club/doki7/ffm/package-info.java b/src/club/doki7/ffm/package-info.java new file mode 100644 index 0000000..e27f6c9 --- /dev/null +++ b/src/club/doki7/ffm/package-info.java @@ -0,0 +1,2 @@ +/// Utility library for Java 22 FFM (Project Panama) APIs. +package club.doki7.ffm; diff --git a/src/club/doki7/ffm/ptr/BytePtr.java b/src/club/doki7/ffm/ptr/BytePtr.java new file mode 100644 index 0000000..58ea5f5 --- /dev/null +++ b/src/club/doki7/ffm/ptr/BytePtr.java @@ -0,0 +1,260 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +/// Represents a pointer to byte(s) in native memory. +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}). To represent null pointer, +/// you may use a Java {@code null} instead. See the documentation of {@link IPointer#segment()} +/// for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record BytePtr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize(); + } + + public byte read() { + return segment.get(ValueLayout.JAVA_BYTE, 0); + } + + public void write(byte value) { + segment.set(ValueLayout.JAVA_BYTE, 0, value); + } + + public byte read(long index) { + return segment.get(ValueLayout.JAVA_BYTE, index); + } + + public void write(long index, byte value) { + segment.set(ValueLayout.JAVA_BYTE, index, value); + } + + public void write(byte @NotNull [] bytes) { + segment.copyFrom(MemorySegment.ofArray(bytes)); + } + + public void writeV(byte value0, byte @NotNull ...values) { + write(value0); + offset(1).write(values); + } + + public void writeString(@NotNull String s) { + segment.setString(0, s); + } + + /// Assume the {@link BytePtr} is a null-terminated string, reads the string from the beginning + /// of the underlying memory segment, until the first NUL byte is encountered. + /// + /// This function requires the size of the underlying memory segment to be set correctly. If the + /// size is not known in advance and correctly set (for example, the {@link BytePtr} or the + /// underlying {@link MemorySegment} is returned from some C API), you may use + /// {@link BytePtr#readString} (note that it is {@link Unsafe}) instead. + public @NotNull String readStringSafe() { + return segment.getString(0); + } + + /// Assumes the {@link BytePtr} is a null-terminated string, reads the string from the beginning + /// of the underlying memory segment, until the first NUL byte is encountered. + /// + /// This function is {@link Unsafe} because it does not check the size of the underlying memory + /// segment. This function is suitable for the cases that the size of the underlying memory + /// segment is not known in advance and correctly set (for example, the {@link BytePtr} or the + /// underlying {@link MemorySegment} is returned from some C API). If the size is correctly set, + /// you may use {@link BytePtr#readStringSafe} instead. + @Unsafe + public @NotNull String readString() { + MemorySegment reinterpreted = segment.reinterpret(Long.MAX_VALUE); + return reinterpreted.getString(0); + } + + /// Assume the {@link BytePtr} is capable of holding at least {@code newSize} bytes, create a + /// new view {@link BytePtr} that uses the same backing storage as this {@link BytePtr}, but + /// with the new size. Since there is actually no way to really check whether the new size is + /// valid, while buffer overflow is undefined behavior, this method is marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull BytePtr reinterpret(long newSize) { + return new BytePtr(segment.reinterpret(newSize)); + } + + public @NotNull BytePtr offset(long offset) { + return new BytePtr(segment.asSlice(offset)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull BytePtr slice(long start, long end) { + return new BytePtr(segment.asSlice(start, end - start)); + } + + public @NotNull BytePtr slice(long end) { + return new BytePtr(segment.asSlice(0, end)); + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(segment); + } + + /// Create a new {@link BytePtr} using {@code segment} as backing storage, with argument + /// validation. + /// + /// If {@code segment} is not big enough to hold at least one byte, that segment is simply + /// considered "empty". See the documentation of {@link IPointer#segment()} for more details. + /// + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} is {@link MemorySegment#NULL}, + /// otherwise a new {@link BytePtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native + public static @Nullable BytePtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + return new BytePtr(segment); + } + + /// Create a new {@link BytePtr} using the same backing storage as {@code buffer}, with argument + /// validation. + /// + /// The main difference between this static method and the {@link #allocate(Arena, ByteBuffer)} + /// method is that this method does not copy the contents of {@code buffer} into a newly + /// allocated {@link MemorySegment}. Instead, the newly created {@link BytePtr} will use the + /// same backing storage as {@code buffer}. Thus, modifications from one side will be visible on + /// the other side. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be referred. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be referred, you may want to call {@link Buffer#rewind()}. + /// + /// @param buffer the {@link ByteBuffer} to use as the backing storage + /// @return a new {@link BytePtr} that uses {@code buffer} as its backing storage + /// @throws IllegalArgumentException if {@code buffer} is not direct + public static @NotNull BytePtr checked(@NotNull ByteBuffer buffer) { + if (!buffer.isDirect()) { + throw new IllegalArgumentException("Buffer must be direct"); + } + + return new BytePtr(MemorySegment.ofBuffer(buffer)); + } + + public static @NotNull BytePtr from(@NotNull IPointer ptr) { + return new BytePtr(ptr.segment()); + } + + public static @NotNull BytePtr allocate(@NotNull Arena arena) { + return new BytePtr(arena.allocate(1)); + } + + public static @NotNull BytePtr allocate(@NotNull Arena arena, long size) { + return new BytePtr(arena.allocate(size)); + } + + public static @NotNull BytePtr allocate(@NotNull Arena arena, byte @NotNull [] bytes) { + return new BytePtr(arena.allocateFrom(ValueLayout.JAVA_BYTE, bytes)); + } + + public static @NotNull BytePtr allocate(@NotNull Arena arena, Collection bytes) { + BytePtr ret = allocate(arena, bytes.size()); + int i = 0; + for (byte value : bytes) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static @NotNull BytePtr allocateV(@NotNull Arena arena, byte value0, byte ...values) { + BytePtr ret = allocate(arena, values.length + 1); + ret.write(value0); + ret.offset(1).segment.copyFrom(MemorySegment.ofArray(values)); + return ret; + } + + /// Allocate a new {@link BytePtr} in {@code arena} and copy the contents of {@code buffer} into + /// the newly allocated {@link BytePtr}. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be copied. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be copied, you may want to call {@link Buffer#rewind()}. + /// + /// + /// @param arena the {@link Arena} to allocate the new {@link BytePtr} in + /// @param buffer the {@link ByteBuffer} to copy the contents from + /// @return a new {@link BytePtr} that contains the contents of {@code buffer} + public static @NotNull BytePtr allocate(@NotNull Arena arena, @NotNull ByteBuffer buffer) { + var s = arena.allocate(buffer.remaining()); + s.copyFrom(MemorySegment.ofBuffer(buffer)); + return new BytePtr(s); + } + + public static @NotNull BytePtr allocateAligned( + @NotNull Arena arena, + long size, + long alignment + ) { + return new BytePtr(arena.allocate(size, alignment)); + } + + public static @NotNull BytePtr allocateString(@NotNull Arena arena, @NotNull String s) { + return new BytePtr(arena.allocateFrom(s)); + } + + /// An iterator over the bytes. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() != 0; + } + + @Override + public Byte next() { + if (!hasNext()) { + throw new NoSuchElementException("No more bytes to read"); + } + byte value = segment.get(ValueLayout.JAVA_BYTE, 0); + segment = segment.asSlice(1); + return value; + } + + private @NotNull MemorySegment segment; + } +} diff --git a/src/club/doki7/ffm/ptr/CLongPtr.java b/src/club/doki7/ffm/ptr/CLongPtr.java new file mode 100644 index 0000000..b78342c --- /dev/null +++ b/src/club/doki7/ffm/ptr/CLongPtr.java @@ -0,0 +1,148 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; + +/// Represents a pointer to 32-bit integer(s) in native memory. +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code NativeLayout.C_LONG.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record CLongPtr(MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / NativeLayout.C_LONG_SIZE; + } + + public long read() { + return NativeLayout.readCLong(segment, 0); + } + + public void write(long value) { + NativeLayout.writeCLong(segment, 0, value); + } + + public long read(long index) { + return NativeLayout.readCLong(segment, index * NativeLayout.C_LONG_SIZE); + } + + public void write(long index, long value) { + NativeLayout.writeCLong(segment, index * NativeLayout.C_LONG_SIZE, value); + } + + /// Assume the {@link CLongPtr} is capable of holding at least {@code newSize} elements, create + /// a new view {@link CLongPtr} that uses the same backing storage as this {@link CLongPtr}, but + /// with the new size. Since there is actually no way to really check whether the new size is + /// valid, while buffer overflow is undefined behavior, this method is marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull CLongPtr reinterpret(long newSize) { + return new CLongPtr(segment.reinterpret(newSize * NativeLayout.C_LONG_SIZE)); + } + + public @NotNull CLongPtr offset(long offset) { + return new CLongPtr(segment.asSlice(offset * NativeLayout.C_LONG_SIZE)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull CLongPtr slice(long start, long end) { + return new CLongPtr(segment.asSlice( + start * NativeLayout.C_LONG_SIZE, + (end - start) * NativeLayout.C_LONG_SIZE + )); + } + + public @NotNull CLongPtr slice(long end) { + return new CLongPtr(segment.asSlice(0, end * NativeLayout.C_LONG_SIZE)); + } + + public @NotNull PrimitiveIterator.OfLong iterator() { + return new Iter(segment); + } + + /// Create a new {@link CLongPtr} with the given {@link MemorySegment} as the backing storage, + /// with argument validation. + /// + /// This function does not ensure {@code segment}'s size to be a multiple of + /// {@link NativeLayout#C_LONG_SIZE}, since that several trailing bytes could be automatically + /// ignored by {@link #size()} method, and usually these bytes does not interfere with FFI + /// operations. If {@code segment} is not big enough to hold at least one element, that segment + /// is simply considered "empty". See the documentation of {@link IPointer#segment()} for more + /// details. + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} is {@link MemorySegment#NULL}, + /// otherwise a new {@link CLongPtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native or not properly aligned + public static @Nullable CLongPtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + if (segment.address() % NativeLayout.C_LONG.byteAlignment() != 0) { + throw new IllegalArgumentException("Segment address must be aligned to " + NativeLayout.C_LONG.byteAlignment() + " bytes"); + } + + return new CLongPtr(segment); + } + + public static @NotNull CLongPtr allocate(@NotNull Arena arena) { + return new CLongPtr(arena.allocate(NativeLayout.C_LONG)); + } + + public static @NotNull CLongPtr allocate(@NotNull Arena arena, long size) { + return new CLongPtr(arena.allocate(NativeLayout.C_LONG, size)); + } + + /// An iterator over the integers. + private static final class Iter implements PrimitiveIterator.OfLong { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= NativeLayout.C_LONG_SIZE; + } + + @Override + public long nextLong() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements to read"); + } + long value = NativeLayout.readCLong(segment, 0); + segment = segment.asSlice(NativeLayout.C_LONG_SIZE); + return value; + } + + private @NotNull MemorySegment segment; + } +} diff --git a/src/club/doki7/ffm/ptr/DoublePtr.java b/src/club/doki7/ffm/ptr/DoublePtr.java new file mode 100644 index 0000000..7392818 --- /dev/null +++ b/src/club/doki7/ffm/ptr/DoublePtr.java @@ -0,0 +1,238 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.Buffer; +import java.nio.DoubleBuffer; +import java.util.Collection; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; + +/// Represents a pointer to 64-bit double-precision float(s) in native memory +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link ValueLayout.OfDouble#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record DoublePtr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / Double.BYTES; + } + + public double read() { + return segment.get(ValueLayout.JAVA_DOUBLE, 0); + } + + public void write(double value) { + segment.set(ValueLayout.JAVA_DOUBLE, 0, value); + } + + public double read(long index) { + return segment.get(ValueLayout.JAVA_DOUBLE, index * Double.BYTES); + } + + public void write(long index, double value) { + segment.set(ValueLayout.JAVA_DOUBLE, index * Double.BYTES, value); + } + + public void write(double @NotNull [] array) { + segment.copyFrom(MemorySegment.ofArray(array)); + } + + public void writeV(double value0, double @NotNull ...values) { + write(value0); + offset(1).write(values); + } + + /// Assume the {@link DoublePtr} is capable of holding at least {@code newSize} doubles, create + /// a new view {@link DoublePtr} that uses the same backing storage as this {@link DoublePtr}, + /// but with the new size. Since there is actually no way to really check whether the new size + /// is valid, while buffer overflow is undefined behavior, this method is marked as + /// {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull DoublePtr reinterpret(long newSize) { + return new DoublePtr(segment.reinterpret(newSize * Double.BYTES)); + } + + public @NotNull DoublePtr offset(long offset) { + return new DoublePtr(segment.asSlice(offset * Double.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull DoublePtr slice(long start, long end) { + return new DoublePtr(segment.asSlice(start * Double.BYTES, (end - start) * Double.BYTES)); + } + + public @NotNull DoublePtr slice(long end) { + return new DoublePtr(segment.asSlice(0, end * Double.BYTES)); + } + + /// Create a new {@link DoublePtr} using {@code segment} as backing storage, with argument + /// validation. + /// + /// This function does not ensure {@code segment}'s size to be a multiple of + /// {@link Double#BYTES}, since that several trailing bytes could be automatically ignored by + /// {@link #size()} method, and usually these bytes does not interfere with FFI operations. If + /// {@code segment} is not big enough to hold at least one double, that segment is simply + /// considered "empty". See the documentation of {@link IPointer#segment()} for more details. + /// + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} is {@link MemorySegment#NULL}, + /// otherwise a new {@link DoublePtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native or not properly aligned + public static @Nullable DoublePtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + if (segment.address() % ValueLayout.JAVA_DOUBLE.byteAlignment() != 0) { + throw new IllegalArgumentException("Segment address must be aligned to " + ValueLayout.JAVA_DOUBLE.byteAlignment() + " bytes"); + } + + return new DoublePtr(segment); + } + + @Override + public @NotNull PrimitiveIterator.OfDouble iterator() { + return new Iter(segment); + } + + /// Create a new {@link DoublePtr} using the same backing storage as {@code buffer}, with + /// argument validation. + /// + /// The main difference between this static method and the {@link #allocate(Arena, DoubleBuffer)} + /// method is that this method does not copy the contents of the {@code buffer} into a newly + /// allocated {@link MemorySegment}. Instead, the newly created {@link DoublePtr} will use the + /// same backing storage as {@code buffer}. Thus, modification from one side will be visible on + /// the other side. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be referred. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be referred, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link DoubleBuffer#order()} property. {@link DoublePtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param buffer the {@link DoubleBuffer} to use as the backing storage + /// @return a new {@link DoublePtr} that uses {@code buffer} as its backing storage + /// @throws IllegalArgumentException if {@code buffer} is not direct, or its backing storage is + /// not properly aligned + public static @NotNull DoublePtr checked(@NotNull DoubleBuffer buffer) { + if (!buffer.isDirect()) { + throw new IllegalArgumentException("Buffer must be direct"); + } + + MemorySegment segment = MemorySegment.ofBuffer(buffer); + if (segment.address() % ValueLayout.JAVA_DOUBLE.byteAlignment() != 0) { + throw new IllegalArgumentException("Buffer address must be aligned to " + ValueLayout.JAVA_DOUBLE.byteAlignment() + " bytes"); + } + + return new DoublePtr(segment); + } + + public static @NotNull DoublePtr allocate(@NotNull Arena arena) { + return new DoublePtr(arena.allocate(ValueLayout.JAVA_DOUBLE)); + } + + public static @NotNull DoublePtr allocate(@NotNull Arena arena, long size) { + return new DoublePtr(arena.allocate(ValueLayout.JAVA_DOUBLE, size)); + } + + public static @NotNull DoublePtr allocate(@NotNull Arena arena, double @NotNull [] array) { + return new DoublePtr(arena.allocateFrom(ValueLayout.JAVA_DOUBLE, array)); + } + + public static @NotNull DoublePtr allocate(@NotNull Arena arena, Collection doubles) { + DoublePtr ret = allocate(arena, doubles.size()); + int i = 0; + for (double value : doubles) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static @NotNull DoublePtr allocateV(@NotNull Arena arena, double value0, double ...values) { + DoublePtr ret = allocate(arena, values.length + 1); + ret.write(value0); + ret.offset(1).segment.copyFrom(MemorySegment.ofArray(values)); + return ret; + } + + /// Allocate a new {@link DoublePtr} in {@code arena} and copy the contents of {@code buffer} into + /// the newly allocated {@link DoublePtr}. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be copied. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be copied, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link DoubleBuffer#order()} property. {@link DoublePtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param arena the {@link Arena} to allocate the new {@link DoublePtr} in + /// @param buffer the {@link DoubleBuffer} to copy the contents from + /// @return a new {@link DoublePtr} that contains the contents of {@code buffer} + public static @NotNull DoublePtr allocate(@NotNull Arena arena, @NotNull DoubleBuffer buffer) { + var s = arena.allocate(ValueLayout.JAVA_DOUBLE, buffer.remaining()); + s.copyFrom(MemorySegment.ofBuffer(buffer)); + return new DoublePtr(s); + } + + /// An iterator over the double precision float numbers. + private static final class Iter implements PrimitiveIterator.OfDouble { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= Double.BYTES; + } + + @Override + public double nextDouble() { + if (!hasNext()) { + throw new NoSuchElementException("No more doubles to read"); + } + double value = segment.get(ValueLayout.JAVA_DOUBLE, 0); + segment = segment.asSlice(Double.BYTES); + return value; + } + + private @NotNull MemorySegment segment; + } +} diff --git a/src/club/doki7/ffm/ptr/FloatPtr.java b/src/club/doki7/ffm/ptr/FloatPtr.java new file mode 100644 index 0000000..236b852 --- /dev/null +++ b/src/club/doki7/ffm/ptr/FloatPtr.java @@ -0,0 +1,237 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.Buffer; +import java.nio.FloatBuffer; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +/// Represents a pointer to 32-bit float(s) in native memory +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link ValueLayout.OfFloat#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record FloatPtr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / Float.BYTES; + } + + public float read() { + return segment.get(ValueLayout.JAVA_FLOAT, 0); + } + + public void write(float value) { + segment.set(ValueLayout.JAVA_FLOAT, 0, value); + } + + public float read(long index) { + return segment.get(ValueLayout.JAVA_FLOAT, index * Float.BYTES); + } + + public void write(long index, float value) { + segment.set(ValueLayout.JAVA_FLOAT, index * Float.BYTES, value); + } + + public void write(float @NotNull [] array) { + segment.copyFrom(MemorySegment.ofArray(array)); + } + + public void writeV(float value0, float @NotNull ...values) { + write(value0); + offset(1).write(values); + } + + /// Assume the {@link FloatPtr} is capable of holding at least {@code newSize} floats, create + /// a new view {@link FloatPtr} that uses the same backing storage as this {@link FloatPtr}, but + /// with the new size. Since there is actually no way to really check whether the new size is + /// valid, while buffer overflow is undefined behavior, this method is marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull FloatPtr reinterpret(long newSize) { + return new FloatPtr(segment.reinterpret(newSize * Float.BYTES)); + } + + public @NotNull FloatPtr offset(long offset) { + return new FloatPtr(segment.asSlice(offset * Float.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull FloatPtr slice(long start, long end) { + return new FloatPtr(segment.asSlice(start * Float.BYTES, (end - start) * Float.BYTES)); + } + + public @NotNull FloatPtr slice(long end) { + return new FloatPtr(segment.asSlice(0, end * Float.BYTES)); + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(segment); + } + + /// Create a new {@link FloatPtr} using {@code segment} as backing storage, with argument + /// validation. + /// + /// This function does not ensure {@code segment}'s size to be a multiple of + /// {@link Float#BYTES}, since that several trailing bytes could be automatically ignored by + /// {@link #size()} method, and usually these bytes does not interfere with FFI operations. If + /// {@code segment} is not big enough to hold at least one float, that segment is simply + /// considered "empty". See the documentation of {@link IPointer#segment()} for more details. + /// + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} is {@link MemorySegment#NULL}, + /// otherwise a new {@link FloatPtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native or not properly aligned + public static @Nullable FloatPtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + if (segment.address() % ValueLayout.JAVA_FLOAT.byteAlignment() != 0) { + throw new IllegalArgumentException("Segment address must be aligned to " + ValueLayout.JAVA_FLOAT.byteAlignment() + " bytes"); + } + + return new FloatPtr(segment); + } + + /// Create a new {@link FloatPtr} using the same backing storage as {@code buffer}, with + /// argument validation. + /// + /// The main difference between this static method and the {@link #allocate(Arena, FloatBuffer)} + /// method is that this method does not copy the contents of the {@code buffer} into a newly + /// allocated {@link MemorySegment}. Instead, the newly created {@link FloatPtr} will use the + /// same backing storage as {@code buffer}. Thus, modification from one side will be visible on + /// the other side. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be referred. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be referred, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link FloatBuffer#order()} property. {@link FloatPtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param buffer the {@link FloatBuffer} to use as the backing storage + /// @return a new {@link FloatPtr} that uses {@code buffer} as its backing storage + /// @throws IllegalArgumentException if {@code buffer} is not direct, or its backing storage is + /// not properly aligned + public static @NotNull FloatPtr checked(@NotNull FloatBuffer buffer) { + if (!buffer.isDirect()) { + throw new IllegalArgumentException("Buffer must be direct"); + } + + MemorySegment segment = MemorySegment.ofBuffer(buffer); + if (segment.address() % ValueLayout.JAVA_FLOAT.byteAlignment() != 0) { + throw new IllegalArgumentException("Buffer address must be aligned to " + ValueLayout.JAVA_FLOAT.byteAlignment() + " bytes"); + } + + return new FloatPtr(segment); + } + + public static @NotNull FloatPtr allocate(@NotNull Arena arena) { + return new FloatPtr(arena.allocate(ValueLayout.JAVA_FLOAT)); + } + + public static @NotNull FloatPtr allocate(@NotNull Arena arena, long size) { + return new FloatPtr(arena.allocate(ValueLayout.JAVA_FLOAT, size)); + } + + public static @NotNull FloatPtr allocate(@NotNull Arena arena, float @NotNull [] array) { + return new FloatPtr(arena.allocateFrom(ValueLayout.JAVA_FLOAT, array)); + } + + public static @NotNull FloatPtr allocate(@NotNull Arena arena, Collection floats) { + FloatPtr ret = allocate(arena, floats.size()); + int i = 0; + for (Float f : floats) { + ret.write(i, f); + i += 1; + } + return ret; + } + + public static @NotNull FloatPtr allocateV(@NotNull Arena arena, float value0, float ...values) { + FloatPtr ret = allocate(arena, values.length + 1); + ret.write(value0); + ret.offset(1).segment.copyFrom(MemorySegment.ofArray(values)); + return ret; + } + + /// Allocate a new {@link FloatPtr} in {@code arena} and copy the contents of {@code buffer} into + /// the newly allocated {@link FloatPtr}. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be copied. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be copied, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link FloatBuffer#order()} property. {@link FloatPtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param arena the {@link Arena} to allocate the new {@link FloatPtr} in + /// @param buffer the {@link FloatBuffer} to copy the contents from + /// @return a new {@link FloatPtr} that contains the contents of {@code buffer} + public static @NotNull FloatPtr allocate(@NotNull Arena arena, @NotNull FloatBuffer buffer) { + var s = arena.allocate(ValueLayout.JAVA_FLOAT, buffer.remaining()); + s.copyFrom(MemorySegment.ofBuffer(buffer)); + return new FloatPtr(s); + } + + /// An iterator over the float numbers. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= Float.BYTES; + } + + @Override + public Float next() { + if (!hasNext()) { + throw new NoSuchElementException("No more floats to read"); + } + float value = segment.get(ValueLayout.JAVA_FLOAT, 0); + segment = segment.asSlice(Float.BYTES); + return value; + } + + private @NotNull MemorySegment segment; + } +} diff --git a/src/club/doki7/ffm/ptr/IntPtr.java b/src/club/doki7/ffm/ptr/IntPtr.java new file mode 100644 index 0000000..8c3b2b5 --- /dev/null +++ b/src/club/doki7/ffm/ptr/IntPtr.java @@ -0,0 +1,253 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.Buffer; +import java.nio.IntBuffer; +import java.util.Collection; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; + +/// Represents a pointer to 32-bit integer(s) in native memory. +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link ValueLayout.OfInt#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record IntPtr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / Integer.BYTES; + } + + public int read() { + return segment.get(ValueLayout.JAVA_INT, 0); + } + + public void write(int value) { + segment.set(ValueLayout.JAVA_INT, 0, value); + } + + public int read(long index) { + return segment.get(ValueLayout.JAVA_INT, index * Integer.BYTES); + } + + public void write(long index, int value) { + segment.set(ValueLayout.JAVA_INT, index * Integer.BYTES, value); + } + + public void write(int @NotNull [] array) { + segment.copyFrom(MemorySegment.ofArray(array)); + } + + public void writeV(int value0, int @NotNull ...values) { + write(value0); + offset(1).write(values); + } + + /// Assume the {@link IntPtr} is capable of holding at least {@code newSize} integers, create + /// a new view {@link IntPtr} that uses the same backing storage as this {@link IntPtr}, but + /// with the new size. Since there is actually no way to really check whether the new size is + /// valid, while buffer overflow is undefined behavior, this method is marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull IntPtr reinterpret(long newSize) { + return new IntPtr(segment.reinterpret(newSize * Integer.BYTES)); + } + + public @NotNull IntPtr offset(long offset) { + return new IntPtr(segment.asSlice(offset * Integer.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull IntPtr slice(long start, long end) { + return new IntPtr(segment.asSlice(start * Integer.BYTES, (end - start) * Integer.BYTES)); + } + + public @NotNull IntPtr slice(long end) { + return new IntPtr(segment.asSlice(0, end * Integer.BYTES)); + } + + @Override + public @NotNull PrimitiveIterator.OfInt iterator() { + return new Iter(segment); + } + + /// Create a new {@link IntPtr} using {@code segment} as backing storage, with argument + /// validation. + /// + /// This function does not ensure {@code segment}'s size to be a multiple of + /// {@link Integer#BYTES}, since that several trailing bytes could be automatically ignored by + /// {@link #size()} method, and usually these bytes does not interfere with FFI operations. + /// If {@code segment} is not big enough to hold at least one integer, that segment is simply + /// considered "empty". See the documentation of {@link IPointer#segment()} for more details. + /// + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} {@link MemorySegment#NULL}, + /// otherwise a new {@link IntPtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native or not properly aligned + public static @Nullable IntPtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + if (segment.address() % ValueLayout.JAVA_INT.byteAlignment() != 0) { + throw new IllegalArgumentException("Segment address must be aligned to " + ValueLayout.JAVA_INT.byteAlignment() + " bytes"); + } + + return new IntPtr(segment); + } + + /// Create a new {@link IntPtr} using the same backing storage as {@code buffer}, with argument + /// validation. + /// + /// The main difference between this static method and the {@link #allocate(Arena, IntBuffer)} + /// method is that this method does not copy the contents of {@code buffer} into a newly + /// allocated {@link MemorySegment}. Instead, the newly created {@link IntPtr} will use the same + /// backing storage as {@code buffer}. Thus, modifications from one side will be visible on the + /// other side. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be referred. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be referred, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link IntBuffer#order()} property. {@link IntPtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param buffer the {@link IntBuffer} to use as the backing storage + /// @return a new {@link IntPtr} that uses {@code buffer} as its backing storage + /// @throws IllegalArgumentException if {@code buffer} is not direct, or its backing storage is + /// not properly aligned + public static @NotNull IntPtr checked(@NotNull IntBuffer buffer) { + if (!buffer.isDirect()) { + throw new IllegalArgumentException("Buffer must be direct"); + } + + MemorySegment segment = MemorySegment.ofBuffer(buffer); + if (segment.address() % ValueLayout.JAVA_INT.byteAlignment() != 0) { + throw new IllegalArgumentException("Buffer address must be aligned to " + ValueLayout.JAVA_INT.byteAlignment() + " bytes"); + } + + return new IntPtr(segment); + } + + public static @NotNull IntPtr allocate(@NotNull Arena arena) { + return new IntPtr(arena.allocate(ValueLayout.JAVA_INT)); + } + + public static @NotNull IntPtr allocate(@NotNull Arena arena, long size) { + return new IntPtr(arena.allocate(ValueLayout.JAVA_INT, size)); + } + + public static @NotNull IntPtr allocate(@NotNull Arena arena, int @NotNull [] array) { + return new IntPtr(arena.allocateFrom(ValueLayout.JAVA_INT, array)); + } + + public static @NotNull IntPtr allocate(@NotNull Arena arena, Collection ints) { + IntPtr ret = allocate(arena, ints.size()); + int i = 0; + for (Integer value : ints) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static @NotNull IntPtr allocateV(@NotNull Arena arena, int value0, int ...values) { + IntPtr ret = allocate(arena, values.length + 1); + ret.write(value0); + ret.offset(1).segment.copyFrom(MemorySegment.ofArray(values)); + return ret; + } + + /// Allocate a new {@link IntPtr} in {@code arena} and copy the contents of {@code array} into + /// the newly allocated {@link IntPtr}. + /// + /// Be aware that if the length of {@code array} is not a multiple of {@link Integer#BYTES}, the + /// residual bytes will be simply discarded. + /// + /// @param arena the {@link Arena} to allocate the new {@link IntPtr} in + /// @param array the {@code byte} array to copy the contents from + /// @return a new {@link IntPtr} that contains the contents of {@code array} + public static @NotNull IntPtr allocate(@NotNull Arena arena, byte @NotNull [] array) { + var segment = arena.allocate(ValueLayout.JAVA_INT, array.length / Integer.BYTES); + segment.copyFrom(MemorySegment.ofArray(array)); + return new IntPtr(segment); + } + + /// Allocate a new {@link IntPtr} in {@code arena} and copy the contents of {@code buffer} into + /// the newly allocated {@link IntPtr}. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be copied. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be copied, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link IntBuffer#order()} property. {@link IntPtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param arena the {@link Arena} to allocate the new {@link IntPtr} in + /// @param buffer the {@link IntBuffer} to copy the contents from + /// @return a new {@link IntPtr} that contains the contents of {@code buffer} + public static @NotNull IntPtr allocate(@NotNull Arena arena, @NotNull IntBuffer buffer) { + MemorySegment s = arena.allocate(ValueLayout.JAVA_INT, buffer.remaining()); + s.copyFrom(MemorySegment.ofBuffer(buffer)); + + return new IntPtr(s); + } + + /// An iterator over the integers. + private static final class Iter implements PrimitiveIterator.OfInt { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= Integer.BYTES; + } + + @Override + public int nextInt() { + if (!hasNext()) { + throw new NoSuchElementException("No more integers to read"); + } + int value = segment.get(ValueLayout.JAVA_INT, 0); + segment = segment.asSlice(Integer.BYTES); + return value; + } + + private @NotNull MemorySegment segment; + } +} diff --git a/src/club/doki7/ffm/ptr/LongPtr.java b/src/club/doki7/ffm/ptr/LongPtr.java new file mode 100644 index 0000000..5541b0e --- /dev/null +++ b/src/club/doki7/ffm/ptr/LongPtr.java @@ -0,0 +1,241 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.Buffer; +import java.nio.LongBuffer; +import java.util.Collection; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; +/// Represents a pointer to 64-bit long integer(s) in native memory. +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link ValueLayout.OfLong#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record LongPtr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / Long.BYTES; + } + + public long read() { + return segment.get(ValueLayout.JAVA_LONG, 0); + } + + public void write(long value) { + segment.set(ValueLayout.JAVA_LONG, 0, value); + } + + public long read(long index) { + return segment.get(ValueLayout.JAVA_LONG, index * Long.BYTES); + } + + public void write(long index, long value) { + segment.set(ValueLayout.JAVA_LONG, index * Long.BYTES, value); + } + + public void write(long @NotNull [] array) { + segment.copyFrom(MemorySegment.ofArray(array)); + } + + public void writeV(long value0, long @NotNull ...values) { + write(value0); + offset(1).write(values); + } + + /// Assume the {@link LongPtr} is capable of holding at least {@code newSize} long integers, + /// create a new view {@link LongPtr} that uses the same backing storage as this + /// {@link LongPtr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull LongPtr reinterpret(long newSize) { + return new LongPtr(segment.reinterpret(newSize * Long.BYTES)); + } + + public @NotNull LongPtr offset(long offset) { + return new LongPtr(segment.asSlice(offset * Long.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull LongPtr slice(long start, long end) { + return new LongPtr(segment.asSlice(start * Long.BYTES, (end - start) * Long.BYTES)); + } + + public @NotNull LongPtr slice(long end) { + return new LongPtr(segment.asSlice(0, end * Long.BYTES)); + } + + @Override + public @NotNull PrimitiveIterator.OfLong iterator() { + return new Iter(segment); + } + + /// Create a new {@link LongPtr} using {@code segment} as backing storage, with argument + /// validation. + /// + /// This function does not ensure {@code segment}'s size to be a multiple of + /// {@link Long#BYTES}, since that several trailing bytes could be automatically ignored by + /// {@link #size()} method, and usually these bytes does not interfere with FFI operations. + /// If {@code segment} is not big enough to hold at least one integer, that segment is simply + /// considered "empty". See the documentation of {@link IPointer#segment()} for more details. + /// + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} is {@link MemorySegment#NULL}, + /// otherwise a new {@link LongPtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native or not properly aligned + public static @Nullable LongPtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + if (segment.address() % ValueLayout.JAVA_LONG.byteAlignment() != 0) { + throw new IllegalArgumentException("Segment address must be aligned to " + ValueLayout.JAVA_LONG.byteAlignment() + " bytes"); + } + + return new LongPtr(segment); + } + + /// Create a new {@link LongPtr} using the same backing storage as {@code buffer}, with argument + /// validation. + /// + /// The main difference between this static method and the {@link #allocate(Arena, LongBuffer)} + /// method is that this method does not copy the contents of {@code buffer} into a newly + /// allocated {@link MemorySegment}. Instead, the newly created {@link LongPtr} will use the + /// same backing storage as {@code buffer}. Thus, modifications from one side will be visible on + /// the other side. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be referred. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be referred, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link LongBuffer#order()} property. {@link LongPtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param buffer the {@link LongBuffer} to use as the backing storage + /// @return a new {@link LongPtr} that uses {@code buffer} as its backing storage + /// @throws IllegalArgumentException if {@code buffer} is not direct, or its backing storage is + /// not properly aligned + public static @NotNull LongPtr checked(@NotNull LongBuffer buffer) { + if (!buffer.isDirect()) { + throw new IllegalArgumentException("Buffer must be direct"); + } + + MemorySegment segment = MemorySegment.ofBuffer(buffer); + if (segment.address() % ValueLayout.JAVA_LONG.byteAlignment() != 0) { + throw new IllegalArgumentException("Buffer address must be aligned to " + ValueLayout.JAVA_LONG.byteAlignment() + " bytes"); + } + + return new LongPtr(segment); + } + + public static @NotNull LongPtr allocate(@NotNull Arena arena) { + return new LongPtr(arena.allocate(ValueLayout.JAVA_LONG)); + } + + public static @NotNull LongPtr allocate(@NotNull Arena arena, long size) { + return new LongPtr(arena.allocate(ValueLayout.JAVA_LONG, size)); + } + + public static @NotNull LongPtr allocate(@NotNull Arena arena, long @NotNull [] array) { + return new LongPtr(arena.allocateFrom(ValueLayout.JAVA_LONG, array)); + } + + public static @NotNull LongPtr allocate(@NotNull Arena arena, Collection longs) { + LongPtr ret = allocate(arena, longs.size()); + int i = 0; + for (long value : longs) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static @NotNull LongPtr allocateV(@NotNull Arena arena, long value0, long ...values) { + LongPtr ret = allocate(arena, values.length + 1); + ret.write(value0); + ret.offset(1).segment.copyFrom(MemorySegment.ofArray(values)); + return ret; + } + + /// Allocate a new {@link LongPtr} in {@code arena} and copy the contents of {@code buffer} into + /// the newly allocated {@link LongPtr}. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be copied. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be copied, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link LongBuffer#order()} property. {@link LongPtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param arena the {@link Arena} to allocate the new {@link LongPtr} in + /// @param buffer the {@link LongBuffer} to copy the contents from + /// @return a new {@link LongPtr} that contains the contents of {@code buffer} + public static @NotNull LongPtr allocate(@NotNull Arena arena, @NotNull LongBuffer buffer) { + MemorySegment s = arena.allocate( + ValueLayout.JAVA_LONG, + (long) buffer.remaining() * Long.BYTES + ); + s.copyFrom(MemorySegment.ofBuffer(buffer)); + + return new LongPtr(s); + } + + /// An iterator over the long integers. + private static final class Iter implements PrimitiveIterator.OfLong { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= Long.BYTES; + } + + @Override + public long nextLong() { + if (!hasNext()) { + throw new NoSuchElementException("No more long integers to read"); + } + long value = segment.get(ValueLayout.JAVA_LONG, 0); + segment = segment.asSlice(Long.BYTES); + return value; + } + + private @NotNull MemorySegment segment; + } +} diff --git a/src/club/doki7/ffm/ptr/PointerPtr.java b/src/club/doki7/ffm/ptr/PointerPtr.java new file mode 100644 index 0000000..dbba1f3 --- /dev/null +++ b/src/club/doki7/ffm/ptr/PointerPtr.java @@ -0,0 +1,281 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.AddressLayout; +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +/// Represents a pointer to pointer(s) in native memory. +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record PointerPtr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @NotNull MemorySegment read() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public void write(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void write(@Nullable IPointer pointer) { + if (pointer != null) { + write(pointer.segment()); + } else { + write(MemorySegment.NULL); + } + } + + public @NotNull MemorySegment read(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void write(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + public void write(long index, @Nullable IPointer pointer) { + if (pointer != null) { + write(index, pointer.segment()); + } else { + write(index, MemorySegment.NULL); + } + } + + /// Assume the {@link PointerPtr} is capable of holding at least {@code newSize} pointers, + /// create a new view {@link PointerPtr} that uses the same backing storage as this + /// {@link PointerPtr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull PointerPtr reinterpret(long newSize) { + return new PointerPtr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public @NotNull PointerPtr offset(long offset) { + return new PointerPtr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull PointerPtr slice(long start, long end) { + return new PointerPtr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public @NotNull PointerPtr slice(long end) { + return new PointerPtr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(segment); + } + + /// Create a new {@link PointerPtr} using {@code segment} as backing storage, with argument + /// validation. + /// + /// This function does not ensure {@code segment}'s size to be a multiple of + /// {@link AddressLayout#byteSize()}, since that several trailing bytes could be automatically + /// ignored by {@link #size()} method, and usually these bytes does not interfere with FFI + /// operations. If {@code segment} is not big enough to hold at least one pointer, that segment + /// is simply considered "empty". See the documentation of {@link IPointer#segment()} for more + /// details. + /// + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} is {@link MemorySegment#NULL}, + /// otherwise a new {@link PointerPtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native or not properly aligned + public static @Nullable PointerPtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + if (segment.byteSize() % ValueLayout.ADDRESS.byteSize() != 0) { + throw new IllegalArgumentException("Segment size must be a multiple of " + ValueLayout.ADDRESS.byteSize()); + } + + return new PointerPtr(segment); + } + + public static @NotNull PointerPtr allocate(@NotNull Arena arena) { + return new PointerPtr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static @NotNull PointerPtr allocate(@NotNull Arena arena, long size) { + return new PointerPtr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static @NotNull PointerPtr allocate( + @NotNull Arena arena, + Collection<@Nullable IPointer> pointers + ) { + PointerPtr ret = allocate(arena, pointers.size()); + int i = 0; + for (IPointer pointer : pointers) { + if (pointer != null) { + ret.write(i, pointer.segment()); + } else { + ret.write(i, MemorySegment.NULL); + } + i += 1; + } + return ret; + } + + public static @NotNull PointerPtr allocateR( + @NotNull Arena arena, + Collection<@NotNull MemorySegment> segments + ) { + PointerPtr ret = allocate(arena, segments.size()); + int i = 0; + for (MemorySegment segment : segments) { + ret.write(i, segment); + i += 1; + } + return ret; + } + + public static @NotNull PointerPtr allocateV( + @NotNull Arena arena, + @Nullable IPointer pointer0, + @Nullable IPointer ...pointers + ) { + PointerPtr ret = allocate(arena, pointers.length + 1); + ret.write(pointer0 != null ? pointer0.segment() : MemorySegment.NULL); + for (int i = 0; i < pointers.length; i++) { + if (pointers[i] != null) { + //noinspection DataFlowIssue + ret.write(i + 1, pointers[i].segment()); + } + } + return ret; + } + + public static @NotNull PointerPtr allocateV( + @NotNull Arena arena, + @NotNull MemorySegment segment0, + @NotNull MemorySegment ...segments + ) { + PointerPtr ret = allocate(arena, segments.length + 1); + ret.write(segment0); + for (int i = 0; i < segments.length; i++) { + ret.write(i + 1, segments[i]); + } + return ret; + } + + public static @NotNull PointerPtr allocateStrings( + @NotNull Arena arena, + @Nullable String string0, + @Nullable String @NotNull ...strings + ) { + PointerPtr ret = allocate(arena, strings.length + 1); + if (string0 != null) { + ret.write(0, arena.allocateFrom(string0)); + } else { + ret.write(0, MemorySegment.NULL); + } + for (int i = 0; i < strings.length; i++) { + if (strings[i] != null) { + ret.write(i + 1, arena.allocateFrom(strings[i])); + } else { + ret.write(i + 1, MemorySegment.NULL); + } + } + return ret; + } + + public static @NotNull PointerPtr allocateStrings( + @NotNull Arena arena, + @Nullable String @NotNull [] strings + ) { + PointerPtr ret = allocate(arena, strings.length); + for (int i = 0; i < strings.length; i++) { + if (strings[i] != null) { + ret.write(i, arena.allocateFrom(strings[i])); + } else { + ret.write(i, MemorySegment.NULL); + } + } + return ret; + } + + public static @NotNull PointerPtr allocateStrings( + @NotNull Arena arena, + @NotNull Collection<@Nullable String> strings + ) { + PointerPtr ret = allocate(arena, strings.size()); + int i = 0; + for (String string : strings) { + if (string != null) { + ret.write(i, arena.allocateFrom(string)); + } else { + ret.write(i, MemorySegment.NULL); + } + i += 1; + } + return ret; + } + + /// An iterator over the pointers. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @NotNull MemorySegment next() { + if (!hasNext()) { + throw new NoSuchElementException("No more pointers to read"); + } + MemorySegment value = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return value; + } + + private @NotNull MemorySegment segment; + } +} diff --git a/src/club/doki7/ffm/ptr/ShortPtr.java b/src/club/doki7/ffm/ptr/ShortPtr.java new file mode 100644 index 0000000..738d0e6 --- /dev/null +++ b/src/club/doki7/ffm/ptr/ShortPtr.java @@ -0,0 +1,241 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.Buffer; +import java.nio.ShortBuffer; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +/// Represents a pointer to 16-bit short integer(s) in native memory. +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link ValueLayout.OfShort#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record ShortPtr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / Short.BYTES; + } + + public short read() { + return segment.get(ValueLayout.JAVA_SHORT, 0); + } + + public void write(short value) { + segment.set(ValueLayout.JAVA_SHORT, 0, value); + } + + public short read(long index) { + return segment.get(ValueLayout.JAVA_SHORT, index * Short.BYTES); + } + + public void write(long index, short value) { + segment.set(ValueLayout.JAVA_SHORT, index * Short.BYTES, value); + } + + public void write(short @NotNull [] values) { + segment.copyFrom(MemorySegment.ofArray(values)); + } + + public void writeV(short value0, short @NotNull ...values) { + write(value0); + offset(1).write(values); + } + + /// Assume the {@link ShortPtr} is capable of holding at least {@code newSize} short integers, + /// create a new view {@link ShortPtr} that uses the same backing storage as this + /// {@link ShortPtr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull ShortPtr reinterpret(long newSize) { + return new ShortPtr(segment.reinterpret(newSize * Short.BYTES)); + } + + public @NotNull ShortPtr offset(long offset) { + return new ShortPtr(segment.asSlice(offset * Short.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull ShortPtr slice(long start, long end) { + return new ShortPtr(segment.asSlice(start * Short.BYTES, (end - start) * Short.BYTES)); + } + + public @NotNull ShortPtr slice(long end) { + return new ShortPtr(segment.asSlice(0, end * Short.BYTES)); + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(segment); + } + + /// Create a new {@link ShortPtr} using {@code segment} as backing storage, with argument + /// validation. + /// + /// This function does not ensure {@code segment}'s size to be a multiple of + /// {@link Short#BYTES}, since that several trailing bytes could be automatically ignored by + /// {@link #size()} method, and usually these bytes does not interfere with FFI operations. + /// If {@code segment} is not big enough to hold at least one short integer, that segment is + /// simply considered "empty". See the documentation of {@link IPointer#segment()} for more + /// details. + /// + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} is {@link MemorySegment#NULL}, + /// otherwise a new {@link ShortPtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native or not properly aligned + public static @Nullable ShortPtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + if (segment.address() % ValueLayout.JAVA_SHORT.byteAlignment() != 0) { + throw new IllegalArgumentException("Segment address must be aligned to " + ValueLayout.JAVA_SHORT.byteAlignment() + " bytes"); + } + + return new ShortPtr(segment); + } + + /// Create a new {@link ShortPtr} using the same backing storage as {@code buffer}, with + /// argument validation. + /// + /// The main difference between this static method and the {@link #allocate(Arena, ShortBuffer)} + /// method is that this method does not copy the contents of {@code buffer} into a newly + /// allocated {@link MemorySegment}. Instead, the newly created {@link ShortPtr} will use the + /// same backing storage as {@code buffer}. Thus, modifications from one side will be visible on + /// the other side. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be referred. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be referred, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link ShortBuffer#order()} property. {@link ShortPtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param buffer the {@link ShortBuffer} to use as the backing storage + /// @return a new {@link ShortPtr} that uses {@code buffer} as its backing storage + /// @throws IllegalArgumentException if {@code buffer} is not direct, or its backing storage is + /// not properly aligned + public static @NotNull ShortPtr checked(@NotNull ShortBuffer buffer) { + if (!buffer.isDirect()) { + throw new IllegalArgumentException("Buffer must be direct"); + } + + MemorySegment segment = MemorySegment.ofBuffer(buffer); + if (segment.address() % ValueLayout.JAVA_SHORT.byteAlignment() != 0) { + throw new IllegalArgumentException("Buffer address must be aligned to " + ValueLayout.JAVA_SHORT.byteAlignment() + " bytes"); + } + + return new ShortPtr(segment); + } + + public static @NotNull ShortPtr allocate(@NotNull Arena arena) { + return new ShortPtr(arena.allocate(ValueLayout.JAVA_SHORT)); + } + + public static @NotNull ShortPtr allocate(@NotNull Arena arena, long size) { + return new ShortPtr(arena.allocate(ValueLayout.JAVA_SHORT, size)); + } + + public static @NotNull ShortPtr allocate(@NotNull Arena arena, short @NotNull [] array) { + return new ShortPtr(arena.allocateFrom(ValueLayout.JAVA_SHORT, array)); + } + + public static @NotNull ShortPtr allocate(@NotNull Arena arena, Collection shorts) { + ShortPtr ret = allocate(arena, shorts.size()); + int i = 0; + for (Short value : shorts) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static @NotNull ShortPtr allocateV(@NotNull Arena arena, short value0, short ...values) { + ShortPtr ret = allocate(arena, values.length + 1); + ret.write(value0); + ret.offset(1).segment.copyFrom(MemorySegment.ofArray(values)); + return ret; + } + + /// Allocate a new {@link ShortPtr} in {@code arena} and copy the contents of {@code buffer} into + /// the newly allocated {@link ShortPtr}. + /// + /// Be careful with {@link java.nio} buffer types' {@link Buffer#position()} property: only the + /// "remaining" (from {@link Buffer#position()} to {@link Buffer#limit()}) part of + /// {@code buffer} will be copied. If you have ever read from {@code buffer}, and you want all + /// the contents of {@code buffer} to be copied, you may want to call {@link Buffer#rewind()}. + /// + /// When handling data types consisting of multiple bytes, also be careful with endianness and + /// {@link ShortBuffer#order()} property. {@link ShortPtr} always uses the native endianness. So + /// if {@code buffer} uses a different endianness, you may want to convert it to the native + /// endianness first. + /// + /// @param arena the {@link Arena} to allocate the new {@link ShortPtr} in + /// @param buffer the {@link ShortBuffer} to copy the contents from + /// @return a new {@link ShortPtr} that contains the contents of {@code buffer} + public static @NotNull ShortPtr allocate(@NotNull Arena arena, @NotNull ShortBuffer buffer) { + MemorySegment s = arena.allocate(ValueLayout.JAVA_SHORT, buffer.remaining()); + s.copyFrom(MemorySegment.ofBuffer(buffer)); + + return new ShortPtr(s); + } + + /// An iterator over the short integers. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= Short.BYTES; + } + + @Override + public Short next() { + if (!hasNext()) { + throw new NoSuchElementException("No more short integers to read"); + } + + short value = segment.get(ValueLayout.JAVA_SHORT, 0); + segment = segment.asSlice(Short.BYTES); + return value; + } + + private @NotNull MemorySegment segment; + } +} diff --git a/src/club/doki7/ffm/ptr/WCharPtr.java b/src/club/doki7/ffm/ptr/WCharPtr.java new file mode 100644 index 0000000..f2f2964 --- /dev/null +++ b/src/club/doki7/ffm/ptr/WCharPtr.java @@ -0,0 +1,222 @@ +package club.doki7.ffm.ptr; + +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.Unsafe; +import club.doki7.ffm.annotation.UnsafeConstructor; +import club.doki7.ffm.annotation.ValueBasedCandidate; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; + +/// Represents a pointer to C `wchar_t` element(s) in native memory. +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code NativeLayout.WCHAR_T.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. For +/// normal users, {@link #checked(MemorySegment)} is a good safe alternative. +@ValueBasedCandidate +@UnsafeConstructor +public record WCharPtr(@Override @NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / NativeLayout.WCHAR_SIZE; + } + + public int read() { + return NativeLayout.readWCharT(segment, 0); + } + + public void write(int value) { + NativeLayout.writeWCharT(segment, 0, value); + } + + public int read(long index) { + return NativeLayout.readWCharT(segment, index * NativeLayout.WCHAR_SIZE); + } + + public void write(long index, int value) { + NativeLayout.writeWCharT(segment, index * NativeLayout.WCHAR_SIZE, value); + } + + /// **(Windows only)** Assume the {@link WCharPtr} is a Windows wide character string, reads the + /// string from the beginning of the underlying memory segment, until the first NUL byte is + /// encountered or the end of the segment is reached. + /// + /// This function requires the size of the underlying segment to be a set correctly. If the + /// size is not known in advance and correctly set (for example, the {@link WCharPtr} or the + /// underlying {@link MemorySegment} is returned from some C API), you may use + /// {@link WCharPtr#readWString()} (note that it is {@link Unsafe}) instead. + public @NotNull String readWStringSafe() { + if (NativeLayout.WCHAR_SIZE != 2) { + throw new UnsupportedOperationException("readWStringSafe only supports 2-byte wchar_t"); + } + + long size = size(); + for (long i = 0; i < size; i++) { + if (read(i) == 0) { + return createStringFromSegment(segment, i); + } + } + + return createStringFromSegment(segment, size); + } + + /// **(Windows only)** Assume the {@link WCharPtr} is a Windows wide character string, reads the + /// wide string from the beginning of the underlying memory segment, until the first NUL byte is + /// encountered. + /// + /// This function is {@link Unsafe} because it does not check the size of the underlying + /// memory segment. This function is suitable for the cases that the size of the underlying + /// memory segment is now known in advance or correctly set (for example, the {@link WCharPtr} + /// or the underlying {@link MemorySegment} is returned from some C API). If the size is + /// correctly set, you may use {@link #readWStringSafe()} instead. + @Unsafe + public @NotNull String readWString() { + if (NativeLayout.WCHAR_SIZE != 2) { + throw new UnsupportedOperationException("readWString only supports 2-byte wchar_t"); + } + + MemorySegment unsizedSegment = segment.reinterpret(Long.MAX_VALUE); + for (long i = 0; i < unsizedSegment.byteSize() / NativeLayout.WCHAR_SIZE; i++) { + if (NativeLayout.readWCharT(unsizedSegment, i * NativeLayout.WCHAR_SIZE) == 0) { + return createStringFromSegment(unsizedSegment, i); + } + } + + throw new IllegalArgumentException("Segment size is too large to read as a string"); + } + + /// Assume the {@link WCharPtr} is capable of holding at least {@code newSize} elements, create + /// a new view {@link WCharPtr} that uses the same backing storage as this {@link WCharPtr}, but + /// with the new size. Since there is actually no way to really check whether the new size is + /// valid, while buffer overflow is undefined behavior, this method is marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + public @NotNull WCharPtr reinterpret(long newSize) { + return new WCharPtr(segment.reinterpret(newSize * NativeLayout.WCHAR_SIZE)); + } + + public @NotNull WCharPtr offset(long offset) { + return new WCharPtr(segment.asSlice(offset * NativeLayout.WCHAR_SIZE)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference. + public @NotNull WCharPtr slice(long start, long end) { + return new WCharPtr(segment.asSlice( + start * NativeLayout.WCHAR_SIZE, + (end - start) * NativeLayout.WCHAR_SIZE + )); + } + + public @NotNull WCharPtr slice(long end) { + return new WCharPtr(segment.asSlice(0, end * NativeLayout.WCHAR_SIZE)); + } + + @Override + public @NotNull PrimitiveIterator.OfInt iterator() { + return new Iter(segment); + } + + /// Create a new {@link WCharPtr} with the given {@link MemorySegment} as the backing storage, + /// with argument validation. + /// + /// This function does not ensure {@code segment}'s size to be a multiple of + /// {@link NativeLayout#WCHAR_SIZE}, since that several trailing bytes could be automatically + /// ignored by {@link #size()} method, and usually these bytes does not interfere with FFI + /// operations. If {@code segment} is not big enough to hold at least one element, that segment + /// is simply considered "empty". See the documentation of {@link IPointer#segment()} for more + /// details. + /// + /// @param segment the {@link MemorySegment} to use as the backing storage + /// @return {@code null} if {@code segment} is {@link MemorySegment#NULL}, + /// otherwise a new {@link WCharPtr} that uses {@code segment} as backing storage + /// @throws IllegalArgumentException if {@code segment} is not native or not properly aligned + public static @Nullable WCharPtr checked(@NotNull MemorySegment segment) { + if (segment.equals(MemorySegment.NULL)) { + return null; + } + + if (!segment.isNative()) { + throw new IllegalArgumentException("Segment must be native"); + } + + if (segment.address() % NativeLayout.WCHAR_T.byteAlignment() != 0) { + throw new IllegalArgumentException("Segment address must be aligned to " + NativeLayout.WCHAR_T.byteAlignment() + " bytes"); + } + + return new WCharPtr(segment); + } + + public static @NotNull WCharPtr allocate(@NotNull Arena arena) { + return new WCharPtr(arena.allocate(NativeLayout.WCHAR_T)); + } + + public static @NotNull WCharPtr allocate(@NotNull Arena arena, long size) { + return new WCharPtr(arena.allocate(NativeLayout.WCHAR_T, size)); + } + + /// **(Windows only)** allocate a new {@link WCharPtr} with the given string as the content. + public static @NotNull WCharPtr allocateWString(@NotNull Arena arena, @NotNull String string) { + if (NativeLayout.WCHAR_SIZE != 2) { + throw new UnsupportedOperationException("allocateWString only supports 2-byte wchar_t"); + } + + char[] charArray = string.toCharArray(); + MemorySegment segment = arena.allocate(NativeLayout.WCHAR_T, charArray.length + 1); + segment.copyFrom(MemorySegment.ofArray(charArray)); + segment.set(ValueLayout.JAVA_SHORT, (long) charArray.length * NativeLayout.WCHAR_SIZE, (short) 0); + return new WCharPtr(segment); + } + + private static final class Iter implements PrimitiveIterator.OfInt { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + private @NotNull MemorySegment segment; + + @Override + public boolean hasNext() { + return segment.byteSize() >= NativeLayout.WCHAR_SIZE; + } + + @Override + public int nextInt() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements to read"); + } + + int value = NativeLayout.readWCharT(segment, 0); + segment = segment.asSlice(NativeLayout.WCHAR_SIZE); + return value; + } + } + + private static String createStringFromSegment(MemorySegment s, long charCount) { + if (charCount > Integer.MAX_VALUE) { + throw new IllegalArgumentException("Segment size is too large to read as a string"); + } + + char[] characters = new char[(int) charCount]; + MemorySegment.ofArray(characters) + .copyFrom(s.asSlice(0, charCount * NativeLayout.WCHAR_SIZE)); + return new String(characters); + } +} diff --git a/src/club/doki7/ffm/ptr/package-info.java b/src/club/doki7/ffm/ptr/package-info.java new file mode 100644 index 0000000..4019ef0 --- /dev/null +++ b/src/club/doki7/ffm/ptr/package-info.java @@ -0,0 +1,33 @@ +/// Utility classes encapsulating {@link java.lang.foreign.MemorySegment}, providing type-safe way +/// to access native memory. +/// +/// ## Quick start +/// +/// Java 22 FFM presents a new way to access native memory, using the new +/// {@link java.lang.foreign.MemorySegment}. However, unlike previous practices like +/// {@link java.nio.Buffer}, {@link java.lang.foreign.MemorySegment} does not have any type +/// information attached to it. Type information are more relevant with read/write operations, +/// not the memory segment itself. +/// +/// In order to fill the gap, a dozen of handy pointer wrapper types are provided in this package. +/// For example, to manipulate a pointer to integer(s), you may use +/// {@link club.doki7.ffm.ptr.IntPtr}: +/// +/// {@snippet : +/// try (Arena arena = Arena.ofConfined()) { +/// IntPtr ptr = IntPtr.allocate(arena); +/// ptr.write(42); +/// assert ptr.read() == 42; +/// +/// // pointer to an array of integers +/// int[] arr = {1, 2, 3, 4, 5}; +/// IntPtr pArray = IntPtr.allocate(arena, arr); // copy from Java array +/// assert pArray.size() == 5; +/// for (int i = 0; i < pArray.size(); i++) { +/// assert pArray.read(i) == arr[i]; +/// } +/// } +/// } +/// +/// See the documentation of classes in this package for more details. +package club.doki7.ffm.ptr; diff --git a/src/club/doki7/ffm/util/UnixUtil.java b/src/club/doki7/ffm/util/UnixUtil.java new file mode 100644 index 0000000..db9f27c --- /dev/null +++ b/src/club/doki7/ffm/util/UnixUtil.java @@ -0,0 +1,51 @@ +package club.doki7.ffm.util; + +import club.doki7.ffm.RawFunctionLoader; +import club.doki7.ffm.library.JavaSystemLibrary; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +public final class UnixUtil { + /// Force the {@link UnixUtil} class to be loaded, in order to avoid some initialization order + /// issues. + /// + /// @implNote The loading of {@link UnixUtil} is done in the static initializer, involving + /// retrieving several function handles. Thus, at the point you call the class methods, if the + /// `UnixUtil` class has not been loaded yet, the loading process may reset the `dlerror` value, + /// which is not what you want. This method is a workaround to force the class to be loaded and + /// initialized, so that the function handles are already retrieved, and the `dlerror` value is + /// not reset. + public static void forceLoad() {} + + public static @Nullable String dlerror() { + try { + MethodHandle h = Objects.requireNonNull(hDlerror); + MemorySegment result = (MemorySegment) h.invokeExact(); + if (result.equals(MemorySegment.NULL)) { + return null; + } + return result.reinterpret(Long.MAX_VALUE).getString(0, StandardCharsets.UTF_8); + } catch (Throwable e) { + return "dlerror failed to retrieve error message: " + e.getMessage(); + } + } + + private static final FunctionDescriptor DESCRIPTOR$dlerror = + FunctionDescriptor.of(ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE)); + private static final @Nullable MethodHandle hDlerror; + + static { + MemorySegment pfnDlerror = JavaSystemLibrary.INSTANCE.load("dlerror"); + if (pfnDlerror.equals(MemorySegment.NULL)) { + hDlerror = null; + } else { + hDlerror = RawFunctionLoader.link(pfnDlerror, DESCRIPTOR$dlerror); + } + } +} diff --git a/src/club/doki7/ffm/util/WindowsUtil.java b/src/club/doki7/ffm/util/WindowsUtil.java new file mode 100644 index 0000000..d1ae17f --- /dev/null +++ b/src/club/doki7/ffm/util/WindowsUtil.java @@ -0,0 +1,37 @@ +package club.doki7.ffm.util; + +import club.doki7.ffm.RawFunctionLoader; +import club.doki7.ffm.library.JavaSystemLibrary; +import org.jetbrains.annotations.Nullable; + +import java.lang.foreign.*; +import java.lang.invoke.MethodHandle; +import java.util.Objects; + +public final class WindowsUtil { + /// @deprecated According to documentation of {@link java.lang.foreign.Linker.Option Linker.Option}, + /// Windows `GetLastError` should be retrieved via `captureCallState`. This function is not + /// correctly implemented and has known bugs. + @Deprecated(forRemoval = true, since = "0.4.2") + public static int getLastError() { + try { + MethodHandle h = Objects.requireNonNull(hGetLastError); + return (int) h.invokeExact(); + } catch (Throwable e) { + return -1; + } + } + + private static final FunctionDescriptor DESCRIPTOR$GetLastError = + FunctionDescriptor.of(ValueLayout.JAVA_INT); + private static final @Nullable MethodHandle hGetLastError; + + static { + MemorySegment pfnGetLastError = JavaSystemLibrary.INSTANCE.load("GetLastError"); + if (pfnGetLastError.equals(MemorySegment.NULL)) { + hGetLastError = null; + } else { + hGetLastError = RawFunctionLoader.link(pfnGetLastError, DESCRIPTOR$GetLastError); + } + } +} diff --git a/src/club/doki7/opencl/CL$Descriptors.class b/src/club/doki7/opencl/CL$Descriptors.class new file mode 100644 index 0000000..95da2f5 Binary files /dev/null and b/src/club/doki7/opencl/CL$Descriptors.class differ diff --git a/src/club/doki7/opencl/CL.class b/src/club/doki7/opencl/CL.class new file mode 100644 index 0000000..f8374e9 Binary files /dev/null and b/src/club/doki7/opencl/CL.class differ diff --git a/src/club/doki7/opencl/CL.java b/src/club/doki7/opencl/CL.java new file mode 100644 index 0000000..9b59ff5 --- /dev/null +++ b/src/club/doki7/opencl/CL.java @@ -0,0 +1,9357 @@ +package club.doki7.opencl; + +import java.lang.foreign.*; +import java.lang.invoke.MethodHandle; +import java.util.Objects; + +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.RawFunctionLoader; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.datatype.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLFunctionTypes.*; + +public final class CL implements CLConstants { + public CL(RawFunctionLoader loader) { + SEGMENT$clGetDeviceIDsFromD3D10KHR = loader.apply("clGetDeviceIDsFromD3D10KHR"); + HANDLE$clGetDeviceIDsFromD3D10KHR = RawFunctionLoader.link(SEGMENT$clGetDeviceIDsFromD3D10KHR, Descriptors.DESCRIPTOR$clGetDeviceIDsFromD3D10KHR); + SEGMENT$clCreateFromD3D10BufferKHR = loader.apply("clCreateFromD3D10BufferKHR"); + HANDLE$clCreateFromD3D10BufferKHR = RawFunctionLoader.link(SEGMENT$clCreateFromD3D10BufferKHR, Descriptors.DESCRIPTOR$clCreateFromD3D10BufferKHR); + SEGMENT$clCreateFromD3D10Texture2DKHR = loader.apply("clCreateFromD3D10Texture2DKHR"); + HANDLE$clCreateFromD3D10Texture2DKHR = RawFunctionLoader.link(SEGMENT$clCreateFromD3D10Texture2DKHR, Descriptors.DESCRIPTOR$clCreateFromD3D10Texture2DKHR); + SEGMENT$clCreateFromD3D10Texture3DKHR = loader.apply("clCreateFromD3D10Texture3DKHR"); + HANDLE$clCreateFromD3D10Texture3DKHR = RawFunctionLoader.link(SEGMENT$clCreateFromD3D10Texture3DKHR, Descriptors.DESCRIPTOR$clCreateFromD3D10Texture3DKHR); + SEGMENT$clEnqueueAcquireD3D10ObjectsKHR = loader.apply("clEnqueueAcquireD3D10ObjectsKHR"); + HANDLE$clEnqueueAcquireD3D10ObjectsKHR = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireD3D10ObjectsKHR, Descriptors.DESCRIPTOR$clEnqueueAcquireD3D10ObjectsKHR); + SEGMENT$clEnqueueReleaseD3D10ObjectsKHR = loader.apply("clEnqueueReleaseD3D10ObjectsKHR"); + HANDLE$clEnqueueReleaseD3D10ObjectsKHR = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseD3D10ObjectsKHR, Descriptors.DESCRIPTOR$clEnqueueReleaseD3D10ObjectsKHR); + SEGMENT$clGetDeviceIDsFromD3D11KHR = loader.apply("clGetDeviceIDsFromD3D11KHR"); + HANDLE$clGetDeviceIDsFromD3D11KHR = RawFunctionLoader.link(SEGMENT$clGetDeviceIDsFromD3D11KHR, Descriptors.DESCRIPTOR$clGetDeviceIDsFromD3D11KHR); + SEGMENT$clCreateFromD3D11BufferKHR = loader.apply("clCreateFromD3D11BufferKHR"); + HANDLE$clCreateFromD3D11BufferKHR = RawFunctionLoader.link(SEGMENT$clCreateFromD3D11BufferKHR, Descriptors.DESCRIPTOR$clCreateFromD3D11BufferKHR); + SEGMENT$clCreateFromD3D11Texture2DKHR = loader.apply("clCreateFromD3D11Texture2DKHR"); + HANDLE$clCreateFromD3D11Texture2DKHR = RawFunctionLoader.link(SEGMENT$clCreateFromD3D11Texture2DKHR, Descriptors.DESCRIPTOR$clCreateFromD3D11Texture2DKHR); + SEGMENT$clCreateFromD3D11Texture3DKHR = loader.apply("clCreateFromD3D11Texture3DKHR"); + HANDLE$clCreateFromD3D11Texture3DKHR = RawFunctionLoader.link(SEGMENT$clCreateFromD3D11Texture3DKHR, Descriptors.DESCRIPTOR$clCreateFromD3D11Texture3DKHR); + SEGMENT$clEnqueueAcquireD3D11ObjectsKHR = loader.apply("clEnqueueAcquireD3D11ObjectsKHR"); + HANDLE$clEnqueueAcquireD3D11ObjectsKHR = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireD3D11ObjectsKHR, Descriptors.DESCRIPTOR$clEnqueueAcquireD3D11ObjectsKHR); + SEGMENT$clEnqueueReleaseD3D11ObjectsKHR = loader.apply("clEnqueueReleaseD3D11ObjectsKHR"); + HANDLE$clEnqueueReleaseD3D11ObjectsKHR = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseD3D11ObjectsKHR, Descriptors.DESCRIPTOR$clEnqueueReleaseD3D11ObjectsKHR); + SEGMENT$clGetDeviceIDsFromDX9MediaAdapterKHR = loader.apply("clGetDeviceIDsFromDX9MediaAdapterKHR"); + HANDLE$clGetDeviceIDsFromDX9MediaAdapterKHR = RawFunctionLoader.link(SEGMENT$clGetDeviceIDsFromDX9MediaAdapterKHR, Descriptors.DESCRIPTOR$clGetDeviceIDsFromDX9MediaAdapterKHR); + SEGMENT$clCreateFromDX9MediaSurfaceKHR = loader.apply("clCreateFromDX9MediaSurfaceKHR"); + HANDLE$clCreateFromDX9MediaSurfaceKHR = RawFunctionLoader.link(SEGMENT$clCreateFromDX9MediaSurfaceKHR, Descriptors.DESCRIPTOR$clCreateFromDX9MediaSurfaceKHR); + SEGMENT$clEnqueueAcquireDX9MediaSurfacesKHR = loader.apply("clEnqueueAcquireDX9MediaSurfacesKHR"); + HANDLE$clEnqueueAcquireDX9MediaSurfacesKHR = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireDX9MediaSurfacesKHR, Descriptors.DESCRIPTOR$clEnqueueAcquireDX9MediaSurfacesKHR); + SEGMENT$clEnqueueReleaseDX9MediaSurfacesKHR = loader.apply("clEnqueueReleaseDX9MediaSurfacesKHR"); + HANDLE$clEnqueueReleaseDX9MediaSurfacesKHR = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseDX9MediaSurfacesKHR, Descriptors.DESCRIPTOR$clEnqueueReleaseDX9MediaSurfacesKHR); + SEGMENT$clGetDeviceIDsFromDX9INTEL = loader.apply("clGetDeviceIDsFromDX9INTEL"); + HANDLE$clGetDeviceIDsFromDX9INTEL = RawFunctionLoader.link(SEGMENT$clGetDeviceIDsFromDX9INTEL, Descriptors.DESCRIPTOR$clGetDeviceIDsFromDX9INTEL); + SEGMENT$clCreateFromDX9MediaSurfaceINTEL = loader.apply("clCreateFromDX9MediaSurfaceINTEL"); + HANDLE$clCreateFromDX9MediaSurfaceINTEL = RawFunctionLoader.link(SEGMENT$clCreateFromDX9MediaSurfaceINTEL, Descriptors.DESCRIPTOR$clCreateFromDX9MediaSurfaceINTEL); + SEGMENT$clEnqueueAcquireDX9ObjectsINTEL = loader.apply("clEnqueueAcquireDX9ObjectsINTEL"); + HANDLE$clEnqueueAcquireDX9ObjectsINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireDX9ObjectsINTEL, Descriptors.DESCRIPTOR$clEnqueueAcquireDX9ObjectsINTEL); + SEGMENT$clEnqueueReleaseDX9ObjectsINTEL = loader.apply("clEnqueueReleaseDX9ObjectsINTEL"); + HANDLE$clEnqueueReleaseDX9ObjectsINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseDX9ObjectsINTEL, Descriptors.DESCRIPTOR$clEnqueueReleaseDX9ObjectsINTEL); + SEGMENT$clCreateEventFromEGLSyncKHR = loader.apply("clCreateEventFromEGLSyncKHR"); + HANDLE$clCreateEventFromEGLSyncKHR = RawFunctionLoader.link(SEGMENT$clCreateEventFromEGLSyncKHR, Descriptors.DESCRIPTOR$clCreateEventFromEGLSyncKHR); + SEGMENT$clCreateFromEGLImageKHR = loader.apply("clCreateFromEGLImageKHR"); + HANDLE$clCreateFromEGLImageKHR = RawFunctionLoader.link(SEGMENT$clCreateFromEGLImageKHR, Descriptors.DESCRIPTOR$clCreateFromEGLImageKHR); + SEGMENT$clEnqueueAcquireEGLObjectsKHR = loader.apply("clEnqueueAcquireEGLObjectsKHR"); + HANDLE$clEnqueueAcquireEGLObjectsKHR = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireEGLObjectsKHR, Descriptors.DESCRIPTOR$clEnqueueAcquireEGLObjectsKHR); + SEGMENT$clEnqueueReleaseEGLObjectsKHR = loader.apply("clEnqueueReleaseEGLObjectsKHR"); + HANDLE$clEnqueueReleaseEGLObjectsKHR = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseEGLObjectsKHR, Descriptors.DESCRIPTOR$clEnqueueReleaseEGLObjectsKHR); + SEGMENT$clLogMessagesToSystemLogAPPLE = loader.apply("clLogMessagesToSystemLogAPPLE"); + HANDLE$clLogMessagesToSystemLogAPPLE = RawFunctionLoader.link(SEGMENT$clLogMessagesToSystemLogAPPLE, Descriptors.DESCRIPTOR$clLogMessagesToSystemLogAPPLE); + SEGMENT$clLogMessagesToStdoutAPPLE = loader.apply("clLogMessagesToStdoutAPPLE"); + HANDLE$clLogMessagesToStdoutAPPLE = RawFunctionLoader.link(SEGMENT$clLogMessagesToStdoutAPPLE, Descriptors.DESCRIPTOR$clLogMessagesToStdoutAPPLE); + SEGMENT$clLogMessagesToStderrAPPLE = loader.apply("clLogMessagesToStderrAPPLE"); + HANDLE$clLogMessagesToStderrAPPLE = RawFunctionLoader.link(SEGMENT$clLogMessagesToStderrAPPLE, Descriptors.DESCRIPTOR$clLogMessagesToStderrAPPLE); + SEGMENT$clIcdGetPlatformIDsKHR = loader.apply("clIcdGetPlatformIDsKHR"); + HANDLE$clIcdGetPlatformIDsKHR = RawFunctionLoader.link(SEGMENT$clIcdGetPlatformIDsKHR, Descriptors.DESCRIPTOR$clIcdGetPlatformIDsKHR); + SEGMENT$clIcdGetFunctionAddressForPlatformKHR = loader.apply("clIcdGetFunctionAddressForPlatformKHR"); + HANDLE$clIcdGetFunctionAddressForPlatformKHR = RawFunctionLoader.link(SEGMENT$clIcdGetFunctionAddressForPlatformKHR, Descriptors.DESCRIPTOR$clIcdGetFunctionAddressForPlatformKHR); + SEGMENT$clIcdSetPlatformDispatchDataKHR = loader.apply("clIcdSetPlatformDispatchDataKHR"); + HANDLE$clIcdSetPlatformDispatchDataKHR = RawFunctionLoader.link(SEGMENT$clIcdSetPlatformDispatchDataKHR, Descriptors.DESCRIPTOR$clIcdSetPlatformDispatchDataKHR); + SEGMENT$clCreateProgramWithILKHR = loader.apply("clCreateProgramWithILKHR"); + HANDLE$clCreateProgramWithILKHR = RawFunctionLoader.link(SEGMENT$clCreateProgramWithILKHR, Descriptors.DESCRIPTOR$clCreateProgramWithILKHR); + SEGMENT$clTerminateContextKHR = loader.apply("clTerminateContextKHR"); + HANDLE$clTerminateContextKHR = RawFunctionLoader.link(SEGMENT$clTerminateContextKHR, Descriptors.DESCRIPTOR$clTerminateContextKHR); + SEGMENT$clCreateCommandQueueWithPropertiesKHR = loader.apply("clCreateCommandQueueWithPropertiesKHR"); + HANDLE$clCreateCommandQueueWithPropertiesKHR = RawFunctionLoader.link(SEGMENT$clCreateCommandQueueWithPropertiesKHR, Descriptors.DESCRIPTOR$clCreateCommandQueueWithPropertiesKHR); + SEGMENT$clReleaseDeviceEXT = loader.apply("clReleaseDeviceEXT"); + HANDLE$clReleaseDeviceEXT = RawFunctionLoader.link(SEGMENT$clReleaseDeviceEXT, Descriptors.DESCRIPTOR$clReleaseDeviceEXT); + SEGMENT$clRetainDeviceEXT = loader.apply("clRetainDeviceEXT"); + HANDLE$clRetainDeviceEXT = RawFunctionLoader.link(SEGMENT$clRetainDeviceEXT, Descriptors.DESCRIPTOR$clRetainDeviceEXT); + SEGMENT$clCreateSubDevicesEXT = loader.apply("clCreateSubDevicesEXT"); + HANDLE$clCreateSubDevicesEXT = RawFunctionLoader.link(SEGMENT$clCreateSubDevicesEXT, Descriptors.DESCRIPTOR$clCreateSubDevicesEXT); + SEGMENT$clEnqueueMigrateMemObjectEXT = loader.apply("clEnqueueMigrateMemObjectEXT"); + HANDLE$clEnqueueMigrateMemObjectEXT = RawFunctionLoader.link(SEGMENT$clEnqueueMigrateMemObjectEXT, Descriptors.DESCRIPTOR$clEnqueueMigrateMemObjectEXT); + SEGMENT$clGetDeviceImageInfoQCOM = loader.apply("clGetDeviceImageInfoQCOM"); + HANDLE$clGetDeviceImageInfoQCOM = RawFunctionLoader.link(SEGMENT$clGetDeviceImageInfoQCOM, Descriptors.DESCRIPTOR$clGetDeviceImageInfoQCOM); + SEGMENT$clEnqueueAcquireGrallocObjectsIMG = loader.apply("clEnqueueAcquireGrallocObjectsIMG"); + HANDLE$clEnqueueAcquireGrallocObjectsIMG = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireGrallocObjectsIMG, Descriptors.DESCRIPTOR$clEnqueueAcquireGrallocObjectsIMG); + SEGMENT$clEnqueueGenerateMipmapIMG = loader.apply("clEnqueueGenerateMipmapIMG"); + HANDLE$clEnqueueGenerateMipmapIMG = RawFunctionLoader.link(SEGMENT$clEnqueueGenerateMipmapIMG, Descriptors.DESCRIPTOR$clEnqueueGenerateMipmapIMG); + SEGMENT$clEnqueueReleaseGrallocObjectsIMG = loader.apply("clEnqueueReleaseGrallocObjectsIMG"); + HANDLE$clEnqueueReleaseGrallocObjectsIMG = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseGrallocObjectsIMG, Descriptors.DESCRIPTOR$clEnqueueReleaseGrallocObjectsIMG); + SEGMENT$clGetKernelSubGroupInfoKHR = loader.apply("clGetKernelSubGroupInfoKHR"); + HANDLE$clGetKernelSubGroupInfoKHR = RawFunctionLoader.link(SEGMENT$clGetKernelSubGroupInfoKHR, Descriptors.DESCRIPTOR$clGetKernelSubGroupInfoKHR); + SEGMENT$clGetKernelSuggestedLocalWorkSizeKHR = loader.apply("clGetKernelSuggestedLocalWorkSizeKHR"); + HANDLE$clGetKernelSuggestedLocalWorkSizeKHR = RawFunctionLoader.link(SEGMENT$clGetKernelSuggestedLocalWorkSizeKHR, Descriptors.DESCRIPTOR$clGetKernelSuggestedLocalWorkSizeKHR); + SEGMENT$clCreateSemaphoreWithPropertiesKHR = loader.apply("clCreateSemaphoreWithPropertiesKHR"); + HANDLE$clCreateSemaphoreWithPropertiesKHR = RawFunctionLoader.link(SEGMENT$clCreateSemaphoreWithPropertiesKHR, Descriptors.DESCRIPTOR$clCreateSemaphoreWithPropertiesKHR); + SEGMENT$clEnqueueWaitSemaphoresKHR = loader.apply("clEnqueueWaitSemaphoresKHR"); + HANDLE$clEnqueueWaitSemaphoresKHR = RawFunctionLoader.link(SEGMENT$clEnqueueWaitSemaphoresKHR, Descriptors.DESCRIPTOR$clEnqueueWaitSemaphoresKHR); + SEGMENT$clEnqueueSignalSemaphoresKHR = loader.apply("clEnqueueSignalSemaphoresKHR"); + HANDLE$clEnqueueSignalSemaphoresKHR = RawFunctionLoader.link(SEGMENT$clEnqueueSignalSemaphoresKHR, Descriptors.DESCRIPTOR$clEnqueueSignalSemaphoresKHR); + SEGMENT$clGetSemaphoreInfoKHR = loader.apply("clGetSemaphoreInfoKHR"); + HANDLE$clGetSemaphoreInfoKHR = RawFunctionLoader.link(SEGMENT$clGetSemaphoreInfoKHR, Descriptors.DESCRIPTOR$clGetSemaphoreInfoKHR); + SEGMENT$clReleaseSemaphoreKHR = loader.apply("clReleaseSemaphoreKHR"); + HANDLE$clReleaseSemaphoreKHR = RawFunctionLoader.link(SEGMENT$clReleaseSemaphoreKHR, Descriptors.DESCRIPTOR$clReleaseSemaphoreKHR); + SEGMENT$clRetainSemaphoreKHR = loader.apply("clRetainSemaphoreKHR"); + HANDLE$clRetainSemaphoreKHR = RawFunctionLoader.link(SEGMENT$clRetainSemaphoreKHR, Descriptors.DESCRIPTOR$clRetainSemaphoreKHR); + SEGMENT$clGetSemaphoreHandleForTypeKHR = loader.apply("clGetSemaphoreHandleForTypeKHR"); + HANDLE$clGetSemaphoreHandleForTypeKHR = RawFunctionLoader.link(SEGMENT$clGetSemaphoreHandleForTypeKHR, Descriptors.DESCRIPTOR$clGetSemaphoreHandleForTypeKHR); + SEGMENT$clReImportSemaphoreSyncFdKHR = loader.apply("clReImportSemaphoreSyncFdKHR"); + HANDLE$clReImportSemaphoreSyncFdKHR = RawFunctionLoader.link(SEGMENT$clReImportSemaphoreSyncFdKHR, Descriptors.DESCRIPTOR$clReImportSemaphoreSyncFdKHR); + SEGMENT$clEnqueueAcquireExternalMemObjectsKHR = loader.apply("clEnqueueAcquireExternalMemObjectsKHR"); + HANDLE$clEnqueueAcquireExternalMemObjectsKHR = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireExternalMemObjectsKHR, Descriptors.DESCRIPTOR$clEnqueueAcquireExternalMemObjectsKHR); + SEGMENT$clEnqueueReleaseExternalMemObjectsKHR = loader.apply("clEnqueueReleaseExternalMemObjectsKHR"); + HANDLE$clEnqueueReleaseExternalMemObjectsKHR = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseExternalMemObjectsKHR, Descriptors.DESCRIPTOR$clEnqueueReleaseExternalMemObjectsKHR); + SEGMENT$clImportMemoryARM = loader.apply("clImportMemoryARM"); + HANDLE$clImportMemoryARM = RawFunctionLoader.link(SEGMENT$clImportMemoryARM, Descriptors.DESCRIPTOR$clImportMemoryARM); + SEGMENT$clSVMAllocARM = loader.apply("clSVMAllocARM"); + HANDLE$clSVMAllocARM = RawFunctionLoader.link(SEGMENT$clSVMAllocARM, Descriptors.DESCRIPTOR$clSVMAllocARM); + SEGMENT$clSVMFreeARM = loader.apply("clSVMFreeARM"); + HANDLE$clSVMFreeARM = RawFunctionLoader.link(SEGMENT$clSVMFreeARM, Descriptors.DESCRIPTOR$clSVMFreeARM); + SEGMENT$clEnqueueSVMFreeARM = loader.apply("clEnqueueSVMFreeARM"); + HANDLE$clEnqueueSVMFreeARM = RawFunctionLoader.link(SEGMENT$clEnqueueSVMFreeARM, Descriptors.DESCRIPTOR$clEnqueueSVMFreeARM); + SEGMENT$clEnqueueSVMMemcpyARM = loader.apply("clEnqueueSVMMemcpyARM"); + HANDLE$clEnqueueSVMMemcpyARM = RawFunctionLoader.link(SEGMENT$clEnqueueSVMMemcpyARM, Descriptors.DESCRIPTOR$clEnqueueSVMMemcpyARM); + SEGMENT$clEnqueueSVMMemFillARM = loader.apply("clEnqueueSVMMemFillARM"); + HANDLE$clEnqueueSVMMemFillARM = RawFunctionLoader.link(SEGMENT$clEnqueueSVMMemFillARM, Descriptors.DESCRIPTOR$clEnqueueSVMMemFillARM); + SEGMENT$clEnqueueSVMMapARM = loader.apply("clEnqueueSVMMapARM"); + HANDLE$clEnqueueSVMMapARM = RawFunctionLoader.link(SEGMENT$clEnqueueSVMMapARM, Descriptors.DESCRIPTOR$clEnqueueSVMMapARM); + SEGMENT$clEnqueueSVMUnmapARM = loader.apply("clEnqueueSVMUnmapARM"); + HANDLE$clEnqueueSVMUnmapARM = RawFunctionLoader.link(SEGMENT$clEnqueueSVMUnmapARM, Descriptors.DESCRIPTOR$clEnqueueSVMUnmapARM); + SEGMENT$clSetKernelArgSVMPointerARM = loader.apply("clSetKernelArgSVMPointerARM"); + HANDLE$clSetKernelArgSVMPointerARM = RawFunctionLoader.link(SEGMENT$clSetKernelArgSVMPointerARM, Descriptors.DESCRIPTOR$clSetKernelArgSVMPointerARM); + SEGMENT$clSetKernelExecInfoARM = loader.apply("clSetKernelExecInfoARM"); + HANDLE$clSetKernelExecInfoARM = RawFunctionLoader.link(SEGMENT$clSetKernelExecInfoARM, Descriptors.DESCRIPTOR$clSetKernelExecInfoARM); + SEGMENT$clCreateAcceleratorINTEL = loader.apply("clCreateAcceleratorINTEL"); + HANDLE$clCreateAcceleratorINTEL = RawFunctionLoader.link(SEGMENT$clCreateAcceleratorINTEL, Descriptors.DESCRIPTOR$clCreateAcceleratorINTEL); + SEGMENT$clGetAcceleratorInfoINTEL = loader.apply("clGetAcceleratorInfoINTEL"); + HANDLE$clGetAcceleratorInfoINTEL = RawFunctionLoader.link(SEGMENT$clGetAcceleratorInfoINTEL, Descriptors.DESCRIPTOR$clGetAcceleratorInfoINTEL); + SEGMENT$clRetainAcceleratorINTEL = loader.apply("clRetainAcceleratorINTEL"); + HANDLE$clRetainAcceleratorINTEL = RawFunctionLoader.link(SEGMENT$clRetainAcceleratorINTEL, Descriptors.DESCRIPTOR$clRetainAcceleratorINTEL); + SEGMENT$clReleaseAcceleratorINTEL = loader.apply("clReleaseAcceleratorINTEL"); + HANDLE$clReleaseAcceleratorINTEL = RawFunctionLoader.link(SEGMENT$clReleaseAcceleratorINTEL, Descriptors.DESCRIPTOR$clReleaseAcceleratorINTEL); + SEGMENT$clCreateEventFromGLsyncKHR = loader.apply("clCreateEventFromGLsyncKHR"); + HANDLE$clCreateEventFromGLsyncKHR = RawFunctionLoader.link(SEGMENT$clCreateEventFromGLsyncKHR, Descriptors.DESCRIPTOR$clCreateEventFromGLsyncKHR); + SEGMENT$clGetGLContextInfoKHR = loader.apply("clGetGLContextInfoKHR"); + HANDLE$clGetGLContextInfoKHR = RawFunctionLoader.link(SEGMENT$clGetGLContextInfoKHR, Descriptors.DESCRIPTOR$clGetGLContextInfoKHR); + SEGMENT$clCreateFromGLBuffer = loader.apply("clCreateFromGLBuffer"); + HANDLE$clCreateFromGLBuffer = RawFunctionLoader.link(SEGMENT$clCreateFromGLBuffer, Descriptors.DESCRIPTOR$clCreateFromGLBuffer); + SEGMENT$clCreateFromGLTexture = loader.apply("clCreateFromGLTexture"); + HANDLE$clCreateFromGLTexture = RawFunctionLoader.link(SEGMENT$clCreateFromGLTexture, Descriptors.DESCRIPTOR$clCreateFromGLTexture); + SEGMENT$clCreateFromGLRenderbuffer = loader.apply("clCreateFromGLRenderbuffer"); + HANDLE$clCreateFromGLRenderbuffer = RawFunctionLoader.link(SEGMENT$clCreateFromGLRenderbuffer, Descriptors.DESCRIPTOR$clCreateFromGLRenderbuffer); + SEGMENT$clGetGLObjectInfo = loader.apply("clGetGLObjectInfo"); + HANDLE$clGetGLObjectInfo = RawFunctionLoader.link(SEGMENT$clGetGLObjectInfo, Descriptors.DESCRIPTOR$clGetGLObjectInfo); + SEGMENT$clGetGLTextureInfo = loader.apply("clGetGLTextureInfo"); + HANDLE$clGetGLTextureInfo = RawFunctionLoader.link(SEGMENT$clGetGLTextureInfo, Descriptors.DESCRIPTOR$clGetGLTextureInfo); + SEGMENT$clEnqueueAcquireGLObjects = loader.apply("clEnqueueAcquireGLObjects"); + HANDLE$clEnqueueAcquireGLObjects = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireGLObjects, Descriptors.DESCRIPTOR$clEnqueueAcquireGLObjects); + SEGMENT$clEnqueueReleaseGLObjects = loader.apply("clEnqueueReleaseGLObjects"); + HANDLE$clEnqueueReleaseGLObjects = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseGLObjects, Descriptors.DESCRIPTOR$clEnqueueReleaseGLObjects); + SEGMENT$clCreateFromGLTexture2D = loader.apply("clCreateFromGLTexture2D"); + HANDLE$clCreateFromGLTexture2D = RawFunctionLoader.link(SEGMENT$clCreateFromGLTexture2D, Descriptors.DESCRIPTOR$clCreateFromGLTexture2D); + SEGMENT$clCreateFromGLTexture3D = loader.apply("clCreateFromGLTexture3D"); + HANDLE$clCreateFromGLTexture3D = RawFunctionLoader.link(SEGMENT$clCreateFromGLTexture3D, Descriptors.DESCRIPTOR$clCreateFromGLTexture3D); + SEGMENT$clGetDeviceIDsFromVA_APIMediaAdapterINTEL = loader.apply("clGetDeviceIDsFromVA_APIMediaAdapterINTEL"); + HANDLE$clGetDeviceIDsFromVA_APIMediaAdapterINTEL = RawFunctionLoader.link(SEGMENT$clGetDeviceIDsFromVA_APIMediaAdapterINTEL, Descriptors.DESCRIPTOR$clGetDeviceIDsFromVA_APIMediaAdapterINTEL); + SEGMENT$clCreateFromVA_APIMediaSurfaceINTEL = loader.apply("clCreateFromVA_APIMediaSurfaceINTEL"); + HANDLE$clCreateFromVA_APIMediaSurfaceINTEL = RawFunctionLoader.link(SEGMENT$clCreateFromVA_APIMediaSurfaceINTEL, Descriptors.DESCRIPTOR$clCreateFromVA_APIMediaSurfaceINTEL); + SEGMENT$clEnqueueAcquireVA_APIMediaSurfacesINTEL = loader.apply("clEnqueueAcquireVA_APIMediaSurfacesINTEL"); + HANDLE$clEnqueueAcquireVA_APIMediaSurfacesINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueAcquireVA_APIMediaSurfacesINTEL, Descriptors.DESCRIPTOR$clEnqueueAcquireVA_APIMediaSurfacesINTEL); + SEGMENT$clEnqueueReleaseVA_APIMediaSurfacesINTEL = loader.apply("clEnqueueReleaseVA_APIMediaSurfacesINTEL"); + HANDLE$clEnqueueReleaseVA_APIMediaSurfacesINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueReleaseVA_APIMediaSurfacesINTEL, Descriptors.DESCRIPTOR$clEnqueueReleaseVA_APIMediaSurfacesINTEL); + SEGMENT$clHostMemAllocINTEL = loader.apply("clHostMemAllocINTEL"); + HANDLE$clHostMemAllocINTEL = RawFunctionLoader.link(SEGMENT$clHostMemAllocINTEL, Descriptors.DESCRIPTOR$clHostMemAllocINTEL); + SEGMENT$clDeviceMemAllocINTEL = loader.apply("clDeviceMemAllocINTEL"); + HANDLE$clDeviceMemAllocINTEL = RawFunctionLoader.link(SEGMENT$clDeviceMemAllocINTEL, Descriptors.DESCRIPTOR$clDeviceMemAllocINTEL); + SEGMENT$clSharedMemAllocINTEL = loader.apply("clSharedMemAllocINTEL"); + HANDLE$clSharedMemAllocINTEL = RawFunctionLoader.link(SEGMENT$clSharedMemAllocINTEL, Descriptors.DESCRIPTOR$clSharedMemAllocINTEL); + SEGMENT$clMemFreeINTEL = loader.apply("clMemFreeINTEL"); + HANDLE$clMemFreeINTEL = RawFunctionLoader.link(SEGMENT$clMemFreeINTEL, Descriptors.DESCRIPTOR$clMemFreeINTEL); + SEGMENT$clMemBlockingFreeINTEL = loader.apply("clMemBlockingFreeINTEL"); + HANDLE$clMemBlockingFreeINTEL = RawFunctionLoader.link(SEGMENT$clMemBlockingFreeINTEL, Descriptors.DESCRIPTOR$clMemBlockingFreeINTEL); + SEGMENT$clGetMemAllocInfoINTEL = loader.apply("clGetMemAllocInfoINTEL"); + HANDLE$clGetMemAllocInfoINTEL = RawFunctionLoader.link(SEGMENT$clGetMemAllocInfoINTEL, Descriptors.DESCRIPTOR$clGetMemAllocInfoINTEL); + SEGMENT$clSetKernelArgMemPointerINTEL = loader.apply("clSetKernelArgMemPointerINTEL"); + HANDLE$clSetKernelArgMemPointerINTEL = RawFunctionLoader.link(SEGMENT$clSetKernelArgMemPointerINTEL, Descriptors.DESCRIPTOR$clSetKernelArgMemPointerINTEL); + SEGMENT$clEnqueueMemsetINTEL = loader.apply("clEnqueueMemsetINTEL"); + HANDLE$clEnqueueMemsetINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueMemsetINTEL, Descriptors.DESCRIPTOR$clEnqueueMemsetINTEL); + SEGMENT$clEnqueueMemFillINTEL = loader.apply("clEnqueueMemFillINTEL"); + HANDLE$clEnqueueMemFillINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueMemFillINTEL, Descriptors.DESCRIPTOR$clEnqueueMemFillINTEL); + SEGMENT$clEnqueueMemcpyINTEL = loader.apply("clEnqueueMemcpyINTEL"); + HANDLE$clEnqueueMemcpyINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueMemcpyINTEL, Descriptors.DESCRIPTOR$clEnqueueMemcpyINTEL); + SEGMENT$clEnqueueMigrateMemINTEL = loader.apply("clEnqueueMigrateMemINTEL"); + HANDLE$clEnqueueMigrateMemINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueMigrateMemINTEL, Descriptors.DESCRIPTOR$clEnqueueMigrateMemINTEL); + SEGMENT$clEnqueueMemAdviseINTEL = loader.apply("clEnqueueMemAdviseINTEL"); + HANDLE$clEnqueueMemAdviseINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueMemAdviseINTEL, Descriptors.DESCRIPTOR$clEnqueueMemAdviseINTEL); + SEGMENT$clCreateBufferWithPropertiesINTEL = loader.apply("clCreateBufferWithPropertiesINTEL"); + HANDLE$clCreateBufferWithPropertiesINTEL = RawFunctionLoader.link(SEGMENT$clCreateBufferWithPropertiesINTEL, Descriptors.DESCRIPTOR$clCreateBufferWithPropertiesINTEL); + SEGMENT$clCreateCommandBufferKHR = loader.apply("clCreateCommandBufferKHR"); + HANDLE$clCreateCommandBufferKHR = RawFunctionLoader.link(SEGMENT$clCreateCommandBufferKHR, Descriptors.DESCRIPTOR$clCreateCommandBufferKHR); + SEGMENT$clFinalizeCommandBufferKHR = loader.apply("clFinalizeCommandBufferKHR"); + HANDLE$clFinalizeCommandBufferKHR = RawFunctionLoader.link(SEGMENT$clFinalizeCommandBufferKHR, Descriptors.DESCRIPTOR$clFinalizeCommandBufferKHR); + SEGMENT$clRetainCommandBufferKHR = loader.apply("clRetainCommandBufferKHR"); + HANDLE$clRetainCommandBufferKHR = RawFunctionLoader.link(SEGMENT$clRetainCommandBufferKHR, Descriptors.DESCRIPTOR$clRetainCommandBufferKHR); + SEGMENT$clReleaseCommandBufferKHR = loader.apply("clReleaseCommandBufferKHR"); + HANDLE$clReleaseCommandBufferKHR = RawFunctionLoader.link(SEGMENT$clReleaseCommandBufferKHR, Descriptors.DESCRIPTOR$clReleaseCommandBufferKHR); + SEGMENT$clEnqueueCommandBufferKHR = loader.apply("clEnqueueCommandBufferKHR"); + HANDLE$clEnqueueCommandBufferKHR = RawFunctionLoader.link(SEGMENT$clEnqueueCommandBufferKHR, Descriptors.DESCRIPTOR$clEnqueueCommandBufferKHR); + SEGMENT$clCommandBarrierWithWaitListKHR = loader.apply("clCommandBarrierWithWaitListKHR"); + HANDLE$clCommandBarrierWithWaitListKHR = RawFunctionLoader.link(SEGMENT$clCommandBarrierWithWaitListKHR, Descriptors.DESCRIPTOR$clCommandBarrierWithWaitListKHR); + SEGMENT$clCommandCopyBufferKHR = loader.apply("clCommandCopyBufferKHR"); + HANDLE$clCommandCopyBufferKHR = RawFunctionLoader.link(SEGMENT$clCommandCopyBufferKHR, Descriptors.DESCRIPTOR$clCommandCopyBufferKHR); + SEGMENT$clCommandCopyBufferRectKHR = loader.apply("clCommandCopyBufferRectKHR"); + HANDLE$clCommandCopyBufferRectKHR = RawFunctionLoader.link(SEGMENT$clCommandCopyBufferRectKHR, Descriptors.DESCRIPTOR$clCommandCopyBufferRectKHR); + SEGMENT$clCommandCopyBufferToImageKHR = loader.apply("clCommandCopyBufferToImageKHR"); + HANDLE$clCommandCopyBufferToImageKHR = RawFunctionLoader.link(SEGMENT$clCommandCopyBufferToImageKHR, Descriptors.DESCRIPTOR$clCommandCopyBufferToImageKHR); + SEGMENT$clCommandCopyImageKHR = loader.apply("clCommandCopyImageKHR"); + HANDLE$clCommandCopyImageKHR = RawFunctionLoader.link(SEGMENT$clCommandCopyImageKHR, Descriptors.DESCRIPTOR$clCommandCopyImageKHR); + SEGMENT$clCommandCopyImageToBufferKHR = loader.apply("clCommandCopyImageToBufferKHR"); + HANDLE$clCommandCopyImageToBufferKHR = RawFunctionLoader.link(SEGMENT$clCommandCopyImageToBufferKHR, Descriptors.DESCRIPTOR$clCommandCopyImageToBufferKHR); + SEGMENT$clCommandFillBufferKHR = loader.apply("clCommandFillBufferKHR"); + HANDLE$clCommandFillBufferKHR = RawFunctionLoader.link(SEGMENT$clCommandFillBufferKHR, Descriptors.DESCRIPTOR$clCommandFillBufferKHR); + SEGMENT$clCommandFillImageKHR = loader.apply("clCommandFillImageKHR"); + HANDLE$clCommandFillImageKHR = RawFunctionLoader.link(SEGMENT$clCommandFillImageKHR, Descriptors.DESCRIPTOR$clCommandFillImageKHR); + SEGMENT$clCommandNDRangeKernelKHR = loader.apply("clCommandNDRangeKernelKHR"); + HANDLE$clCommandNDRangeKernelKHR = RawFunctionLoader.link(SEGMENT$clCommandNDRangeKernelKHR, Descriptors.DESCRIPTOR$clCommandNDRangeKernelKHR); + SEGMENT$clCommandSVMMemcpyKHR = loader.apply("clCommandSVMMemcpyKHR"); + HANDLE$clCommandSVMMemcpyKHR = RawFunctionLoader.link(SEGMENT$clCommandSVMMemcpyKHR, Descriptors.DESCRIPTOR$clCommandSVMMemcpyKHR); + SEGMENT$clCommandSVMMemFillKHR = loader.apply("clCommandSVMMemFillKHR"); + HANDLE$clCommandSVMMemFillKHR = RawFunctionLoader.link(SEGMENT$clCommandSVMMemFillKHR, Descriptors.DESCRIPTOR$clCommandSVMMemFillKHR); + SEGMENT$clGetCommandBufferInfoKHR = loader.apply("clGetCommandBufferInfoKHR"); + HANDLE$clGetCommandBufferInfoKHR = RawFunctionLoader.link(SEGMENT$clGetCommandBufferInfoKHR, Descriptors.DESCRIPTOR$clGetCommandBufferInfoKHR); + SEGMENT$clUpdateMutableCommandsKHR = loader.apply("clUpdateMutableCommandsKHR"); + HANDLE$clUpdateMutableCommandsKHR = RawFunctionLoader.link(SEGMENT$clUpdateMutableCommandsKHR, Descriptors.DESCRIPTOR$clUpdateMutableCommandsKHR); + SEGMENT$clGetMutableCommandInfoKHR = loader.apply("clGetMutableCommandInfoKHR"); + HANDLE$clGetMutableCommandInfoKHR = RawFunctionLoader.link(SEGMENT$clGetMutableCommandInfoKHR, Descriptors.DESCRIPTOR$clGetMutableCommandInfoKHR); + SEGMENT$clRemapCommandBufferKHR = loader.apply("clRemapCommandBufferKHR"); + HANDLE$clRemapCommandBufferKHR = RawFunctionLoader.link(SEGMENT$clRemapCommandBufferKHR, Descriptors.DESCRIPTOR$clRemapCommandBufferKHR); + SEGMENT$clSetContentSizeBufferPoCL = loader.apply("clSetContentSizeBufferPoCL"); + HANDLE$clSetContentSizeBufferPoCL = RawFunctionLoader.link(SEGMENT$clSetContentSizeBufferPoCL, Descriptors.DESCRIPTOR$clSetContentSizeBufferPoCL); + SEGMENT$clGetPlatformIDs = loader.apply("clGetPlatformIDs"); + HANDLE$clGetPlatformIDs = RawFunctionLoader.link(SEGMENT$clGetPlatformIDs, Descriptors.DESCRIPTOR$clGetPlatformIDs); + SEGMENT$clGetPlatformInfo = loader.apply("clGetPlatformInfo"); + HANDLE$clGetPlatformInfo = RawFunctionLoader.link(SEGMENT$clGetPlatformInfo, Descriptors.DESCRIPTOR$clGetPlatformInfo); + SEGMENT$clGetDeviceIDs = loader.apply("clGetDeviceIDs"); + HANDLE$clGetDeviceIDs = RawFunctionLoader.link(SEGMENT$clGetDeviceIDs, Descriptors.DESCRIPTOR$clGetDeviceIDs); + SEGMENT$clGetDeviceInfo = loader.apply("clGetDeviceInfo"); + HANDLE$clGetDeviceInfo = RawFunctionLoader.link(SEGMENT$clGetDeviceInfo, Descriptors.DESCRIPTOR$clGetDeviceInfo); + SEGMENT$clCreateSubDevices = loader.apply("clCreateSubDevices"); + HANDLE$clCreateSubDevices = RawFunctionLoader.link(SEGMENT$clCreateSubDevices, Descriptors.DESCRIPTOR$clCreateSubDevices); + SEGMENT$clRetainDevice = loader.apply("clRetainDevice"); + HANDLE$clRetainDevice = RawFunctionLoader.link(SEGMENT$clRetainDevice, Descriptors.DESCRIPTOR$clRetainDevice); + SEGMENT$clReleaseDevice = loader.apply("clReleaseDevice"); + HANDLE$clReleaseDevice = RawFunctionLoader.link(SEGMENT$clReleaseDevice, Descriptors.DESCRIPTOR$clReleaseDevice); + SEGMENT$clSetDefaultDeviceCommandQueue = loader.apply("clSetDefaultDeviceCommandQueue"); + HANDLE$clSetDefaultDeviceCommandQueue = RawFunctionLoader.link(SEGMENT$clSetDefaultDeviceCommandQueue, Descriptors.DESCRIPTOR$clSetDefaultDeviceCommandQueue); + SEGMENT$clGetDeviceAndHostTimer = loader.apply("clGetDeviceAndHostTimer"); + HANDLE$clGetDeviceAndHostTimer = RawFunctionLoader.link(SEGMENT$clGetDeviceAndHostTimer, Descriptors.DESCRIPTOR$clGetDeviceAndHostTimer); + SEGMENT$clGetHostTimer = loader.apply("clGetHostTimer"); + HANDLE$clGetHostTimer = RawFunctionLoader.link(SEGMENT$clGetHostTimer, Descriptors.DESCRIPTOR$clGetHostTimer); + SEGMENT$clCreateContext = loader.apply("clCreateContext"); + HANDLE$clCreateContext = RawFunctionLoader.link(SEGMENT$clCreateContext, Descriptors.DESCRIPTOR$clCreateContext); + SEGMENT$clCreateContextFromType = loader.apply("clCreateContextFromType"); + HANDLE$clCreateContextFromType = RawFunctionLoader.link(SEGMENT$clCreateContextFromType, Descriptors.DESCRIPTOR$clCreateContextFromType); + SEGMENT$clRetainContext = loader.apply("clRetainContext"); + HANDLE$clRetainContext = RawFunctionLoader.link(SEGMENT$clRetainContext, Descriptors.DESCRIPTOR$clRetainContext); + SEGMENT$clReleaseContext = loader.apply("clReleaseContext"); + HANDLE$clReleaseContext = RawFunctionLoader.link(SEGMENT$clReleaseContext, Descriptors.DESCRIPTOR$clReleaseContext); + SEGMENT$clGetContextInfo = loader.apply("clGetContextInfo"); + HANDLE$clGetContextInfo = RawFunctionLoader.link(SEGMENT$clGetContextInfo, Descriptors.DESCRIPTOR$clGetContextInfo); + SEGMENT$clSetContextDestructorCallback = loader.apply("clSetContextDestructorCallback"); + HANDLE$clSetContextDestructorCallback = RawFunctionLoader.link(SEGMENT$clSetContextDestructorCallback, Descriptors.DESCRIPTOR$clSetContextDestructorCallback); + SEGMENT$clCreateCommandQueueWithProperties = loader.apply("clCreateCommandQueueWithProperties"); + HANDLE$clCreateCommandQueueWithProperties = RawFunctionLoader.link(SEGMENT$clCreateCommandQueueWithProperties, Descriptors.DESCRIPTOR$clCreateCommandQueueWithProperties); + SEGMENT$clRetainCommandQueue = loader.apply("clRetainCommandQueue"); + HANDLE$clRetainCommandQueue = RawFunctionLoader.link(SEGMENT$clRetainCommandQueue, Descriptors.DESCRIPTOR$clRetainCommandQueue); + SEGMENT$clReleaseCommandQueue = loader.apply("clReleaseCommandQueue"); + HANDLE$clReleaseCommandQueue = RawFunctionLoader.link(SEGMENT$clReleaseCommandQueue, Descriptors.DESCRIPTOR$clReleaseCommandQueue); + SEGMENT$clGetCommandQueueInfo = loader.apply("clGetCommandQueueInfo"); + HANDLE$clGetCommandQueueInfo = RawFunctionLoader.link(SEGMENT$clGetCommandQueueInfo, Descriptors.DESCRIPTOR$clGetCommandQueueInfo); + SEGMENT$clCreateBuffer = loader.apply("clCreateBuffer"); + HANDLE$clCreateBuffer = RawFunctionLoader.link(SEGMENT$clCreateBuffer, Descriptors.DESCRIPTOR$clCreateBuffer); + SEGMENT$clCreateBufferWithProperties = loader.apply("clCreateBufferWithProperties"); + HANDLE$clCreateBufferWithProperties = RawFunctionLoader.link(SEGMENT$clCreateBufferWithProperties, Descriptors.DESCRIPTOR$clCreateBufferWithProperties); + SEGMENT$clCreateSubBuffer = loader.apply("clCreateSubBuffer"); + HANDLE$clCreateSubBuffer = RawFunctionLoader.link(SEGMENT$clCreateSubBuffer, Descriptors.DESCRIPTOR$clCreateSubBuffer); + SEGMENT$clCreateImage = loader.apply("clCreateImage"); + HANDLE$clCreateImage = RawFunctionLoader.link(SEGMENT$clCreateImage, Descriptors.DESCRIPTOR$clCreateImage); + SEGMENT$clCreateImageWithProperties = loader.apply("clCreateImageWithProperties"); + HANDLE$clCreateImageWithProperties = RawFunctionLoader.link(SEGMENT$clCreateImageWithProperties, Descriptors.DESCRIPTOR$clCreateImageWithProperties); + SEGMENT$clCreatePipe = loader.apply("clCreatePipe"); + HANDLE$clCreatePipe = RawFunctionLoader.link(SEGMENT$clCreatePipe, Descriptors.DESCRIPTOR$clCreatePipe); + SEGMENT$clRetainMemObject = loader.apply("clRetainMemObject"); + HANDLE$clRetainMemObject = RawFunctionLoader.link(SEGMENT$clRetainMemObject, Descriptors.DESCRIPTOR$clRetainMemObject); + SEGMENT$clReleaseMemObject = loader.apply("clReleaseMemObject"); + HANDLE$clReleaseMemObject = RawFunctionLoader.link(SEGMENT$clReleaseMemObject, Descriptors.DESCRIPTOR$clReleaseMemObject); + SEGMENT$clGetSupportedImageFormats = loader.apply("clGetSupportedImageFormats"); + HANDLE$clGetSupportedImageFormats = RawFunctionLoader.link(SEGMENT$clGetSupportedImageFormats, Descriptors.DESCRIPTOR$clGetSupportedImageFormats); + SEGMENT$clGetMemObjectInfo = loader.apply("clGetMemObjectInfo"); + HANDLE$clGetMemObjectInfo = RawFunctionLoader.link(SEGMENT$clGetMemObjectInfo, Descriptors.DESCRIPTOR$clGetMemObjectInfo); + SEGMENT$clGetImageInfo = loader.apply("clGetImageInfo"); + HANDLE$clGetImageInfo = RawFunctionLoader.link(SEGMENT$clGetImageInfo, Descriptors.DESCRIPTOR$clGetImageInfo); + SEGMENT$clGetPipeInfo = loader.apply("clGetPipeInfo"); + HANDLE$clGetPipeInfo = RawFunctionLoader.link(SEGMENT$clGetPipeInfo, Descriptors.DESCRIPTOR$clGetPipeInfo); + SEGMENT$clSetMemObjectDestructorCallback = loader.apply("clSetMemObjectDestructorCallback"); + HANDLE$clSetMemObjectDestructorCallback = RawFunctionLoader.link(SEGMENT$clSetMemObjectDestructorCallback, Descriptors.DESCRIPTOR$clSetMemObjectDestructorCallback); + SEGMENT$clSetMemObjectDestructorAPPLE = loader.apply("clSetMemObjectDestructorAPPLE"); + HANDLE$clSetMemObjectDestructorAPPLE = RawFunctionLoader.link(SEGMENT$clSetMemObjectDestructorAPPLE, Descriptors.DESCRIPTOR$clSetMemObjectDestructorAPPLE); + SEGMENT$clSVMAlloc = loader.apply("clSVMAlloc"); + HANDLE$clSVMAlloc = RawFunctionLoader.link(SEGMENT$clSVMAlloc, Descriptors.DESCRIPTOR$clSVMAlloc); + SEGMENT$clSVMFree = loader.apply("clSVMFree"); + HANDLE$clSVMFree = RawFunctionLoader.link(SEGMENT$clSVMFree, Descriptors.DESCRIPTOR$clSVMFree); + SEGMENT$clCreateSamplerWithProperties = loader.apply("clCreateSamplerWithProperties"); + HANDLE$clCreateSamplerWithProperties = RawFunctionLoader.link(SEGMENT$clCreateSamplerWithProperties, Descriptors.DESCRIPTOR$clCreateSamplerWithProperties); + SEGMENT$clRetainSampler = loader.apply("clRetainSampler"); + HANDLE$clRetainSampler = RawFunctionLoader.link(SEGMENT$clRetainSampler, Descriptors.DESCRIPTOR$clRetainSampler); + SEGMENT$clReleaseSampler = loader.apply("clReleaseSampler"); + HANDLE$clReleaseSampler = RawFunctionLoader.link(SEGMENT$clReleaseSampler, Descriptors.DESCRIPTOR$clReleaseSampler); + SEGMENT$clGetSamplerInfo = loader.apply("clGetSamplerInfo"); + HANDLE$clGetSamplerInfo = RawFunctionLoader.link(SEGMENT$clGetSamplerInfo, Descriptors.DESCRIPTOR$clGetSamplerInfo); + SEGMENT$clCreateProgramWithSource = loader.apply("clCreateProgramWithSource"); + HANDLE$clCreateProgramWithSource = RawFunctionLoader.link(SEGMENT$clCreateProgramWithSource, Descriptors.DESCRIPTOR$clCreateProgramWithSource); + SEGMENT$clCreateProgramWithBinary = loader.apply("clCreateProgramWithBinary"); + HANDLE$clCreateProgramWithBinary = RawFunctionLoader.link(SEGMENT$clCreateProgramWithBinary, Descriptors.DESCRIPTOR$clCreateProgramWithBinary); + SEGMENT$clCreateProgramWithBuiltInKernels = loader.apply("clCreateProgramWithBuiltInKernels"); + HANDLE$clCreateProgramWithBuiltInKernels = RawFunctionLoader.link(SEGMENT$clCreateProgramWithBuiltInKernels, Descriptors.DESCRIPTOR$clCreateProgramWithBuiltInKernels); + SEGMENT$clCreateProgramWithIL = loader.apply("clCreateProgramWithIL"); + HANDLE$clCreateProgramWithIL = RawFunctionLoader.link(SEGMENT$clCreateProgramWithIL, Descriptors.DESCRIPTOR$clCreateProgramWithIL); + SEGMENT$clRetainProgram = loader.apply("clRetainProgram"); + HANDLE$clRetainProgram = RawFunctionLoader.link(SEGMENT$clRetainProgram, Descriptors.DESCRIPTOR$clRetainProgram); + SEGMENT$clReleaseProgram = loader.apply("clReleaseProgram"); + HANDLE$clReleaseProgram = RawFunctionLoader.link(SEGMENT$clReleaseProgram, Descriptors.DESCRIPTOR$clReleaseProgram); + SEGMENT$clBuildProgram = loader.apply("clBuildProgram"); + HANDLE$clBuildProgram = RawFunctionLoader.link(SEGMENT$clBuildProgram, Descriptors.DESCRIPTOR$clBuildProgram); + SEGMENT$clCompileProgram = loader.apply("clCompileProgram"); + HANDLE$clCompileProgram = RawFunctionLoader.link(SEGMENT$clCompileProgram, Descriptors.DESCRIPTOR$clCompileProgram); + SEGMENT$clLinkProgram = loader.apply("clLinkProgram"); + HANDLE$clLinkProgram = RawFunctionLoader.link(SEGMENT$clLinkProgram, Descriptors.DESCRIPTOR$clLinkProgram); + SEGMENT$clSetProgramReleaseCallback = loader.apply("clSetProgramReleaseCallback"); + HANDLE$clSetProgramReleaseCallback = RawFunctionLoader.link(SEGMENT$clSetProgramReleaseCallback, Descriptors.DESCRIPTOR$clSetProgramReleaseCallback); + SEGMENT$clSetProgramSpecializationConstant = loader.apply("clSetProgramSpecializationConstant"); + HANDLE$clSetProgramSpecializationConstant = RawFunctionLoader.link(SEGMENT$clSetProgramSpecializationConstant, Descriptors.DESCRIPTOR$clSetProgramSpecializationConstant); + SEGMENT$clUnloadPlatformCompiler = loader.apply("clUnloadPlatformCompiler"); + HANDLE$clUnloadPlatformCompiler = RawFunctionLoader.link(SEGMENT$clUnloadPlatformCompiler, Descriptors.DESCRIPTOR$clUnloadPlatformCompiler); + SEGMENT$clGetProgramInfo = loader.apply("clGetProgramInfo"); + HANDLE$clGetProgramInfo = RawFunctionLoader.link(SEGMENT$clGetProgramInfo, Descriptors.DESCRIPTOR$clGetProgramInfo); + SEGMENT$clGetProgramBuildInfo = loader.apply("clGetProgramBuildInfo"); + HANDLE$clGetProgramBuildInfo = RawFunctionLoader.link(SEGMENT$clGetProgramBuildInfo, Descriptors.DESCRIPTOR$clGetProgramBuildInfo); + SEGMENT$clCreateKernel = loader.apply("clCreateKernel"); + HANDLE$clCreateKernel = RawFunctionLoader.link(SEGMENT$clCreateKernel, Descriptors.DESCRIPTOR$clCreateKernel); + SEGMENT$clCreateKernelsInProgram = loader.apply("clCreateKernelsInProgram"); + HANDLE$clCreateKernelsInProgram = RawFunctionLoader.link(SEGMENT$clCreateKernelsInProgram, Descriptors.DESCRIPTOR$clCreateKernelsInProgram); + SEGMENT$clCloneKernel = loader.apply("clCloneKernel"); + HANDLE$clCloneKernel = RawFunctionLoader.link(SEGMENT$clCloneKernel, Descriptors.DESCRIPTOR$clCloneKernel); + SEGMENT$clRetainKernel = loader.apply("clRetainKernel"); + HANDLE$clRetainKernel = RawFunctionLoader.link(SEGMENT$clRetainKernel, Descriptors.DESCRIPTOR$clRetainKernel); + SEGMENT$clReleaseKernel = loader.apply("clReleaseKernel"); + HANDLE$clReleaseKernel = RawFunctionLoader.link(SEGMENT$clReleaseKernel, Descriptors.DESCRIPTOR$clReleaseKernel); + SEGMENT$clSetKernelArg = loader.apply("clSetKernelArg"); + HANDLE$clSetKernelArg = RawFunctionLoader.link(SEGMENT$clSetKernelArg, Descriptors.DESCRIPTOR$clSetKernelArg); + SEGMENT$clSetKernelArgSVMPointer = loader.apply("clSetKernelArgSVMPointer"); + HANDLE$clSetKernelArgSVMPointer = RawFunctionLoader.link(SEGMENT$clSetKernelArgSVMPointer, Descriptors.DESCRIPTOR$clSetKernelArgSVMPointer); + SEGMENT$clSetKernelArgDevicePointerEXT = loader.apply("clSetKernelArgDevicePointerEXT"); + HANDLE$clSetKernelArgDevicePointerEXT = RawFunctionLoader.link(SEGMENT$clSetKernelArgDevicePointerEXT, Descriptors.DESCRIPTOR$clSetKernelArgDevicePointerEXT); + SEGMENT$clSetKernelExecInfo = loader.apply("clSetKernelExecInfo"); + HANDLE$clSetKernelExecInfo = RawFunctionLoader.link(SEGMENT$clSetKernelExecInfo, Descriptors.DESCRIPTOR$clSetKernelExecInfo); + SEGMENT$clGetKernelInfo = loader.apply("clGetKernelInfo"); + HANDLE$clGetKernelInfo = RawFunctionLoader.link(SEGMENT$clGetKernelInfo, Descriptors.DESCRIPTOR$clGetKernelInfo); + SEGMENT$clGetKernelArgInfo = loader.apply("clGetKernelArgInfo"); + HANDLE$clGetKernelArgInfo = RawFunctionLoader.link(SEGMENT$clGetKernelArgInfo, Descriptors.DESCRIPTOR$clGetKernelArgInfo); + SEGMENT$clGetKernelWorkGroupInfo = loader.apply("clGetKernelWorkGroupInfo"); + HANDLE$clGetKernelWorkGroupInfo = RawFunctionLoader.link(SEGMENT$clGetKernelWorkGroupInfo, Descriptors.DESCRIPTOR$clGetKernelWorkGroupInfo); + SEGMENT$clGetKernelSubGroupInfo = loader.apply("clGetKernelSubGroupInfo"); + HANDLE$clGetKernelSubGroupInfo = RawFunctionLoader.link(SEGMENT$clGetKernelSubGroupInfo, Descriptors.DESCRIPTOR$clGetKernelSubGroupInfo); + SEGMENT$clWaitForEvents = loader.apply("clWaitForEvents"); + HANDLE$clWaitForEvents = RawFunctionLoader.link(SEGMENT$clWaitForEvents, Descriptors.DESCRIPTOR$clWaitForEvents); + SEGMENT$clGetEventInfo = loader.apply("clGetEventInfo"); + HANDLE$clGetEventInfo = RawFunctionLoader.link(SEGMENT$clGetEventInfo, Descriptors.DESCRIPTOR$clGetEventInfo); + SEGMENT$clCreateUserEvent = loader.apply("clCreateUserEvent"); + HANDLE$clCreateUserEvent = RawFunctionLoader.link(SEGMENT$clCreateUserEvent, Descriptors.DESCRIPTOR$clCreateUserEvent); + SEGMENT$clRetainEvent = loader.apply("clRetainEvent"); + HANDLE$clRetainEvent = RawFunctionLoader.link(SEGMENT$clRetainEvent, Descriptors.DESCRIPTOR$clRetainEvent); + SEGMENT$clReleaseEvent = loader.apply("clReleaseEvent"); + HANDLE$clReleaseEvent = RawFunctionLoader.link(SEGMENT$clReleaseEvent, Descriptors.DESCRIPTOR$clReleaseEvent); + SEGMENT$clSetUserEventStatus = loader.apply("clSetUserEventStatus"); + HANDLE$clSetUserEventStatus = RawFunctionLoader.link(SEGMENT$clSetUserEventStatus, Descriptors.DESCRIPTOR$clSetUserEventStatus); + SEGMENT$clSetEventCallback = loader.apply("clSetEventCallback"); + HANDLE$clSetEventCallback = RawFunctionLoader.link(SEGMENT$clSetEventCallback, Descriptors.DESCRIPTOR$clSetEventCallback); + SEGMENT$clGetEventProfilingInfo = loader.apply("clGetEventProfilingInfo"); + HANDLE$clGetEventProfilingInfo = RawFunctionLoader.link(SEGMENT$clGetEventProfilingInfo, Descriptors.DESCRIPTOR$clGetEventProfilingInfo); + SEGMENT$clFlush = loader.apply("clFlush"); + HANDLE$clFlush = RawFunctionLoader.link(SEGMENT$clFlush, Descriptors.DESCRIPTOR$clFlush); + SEGMENT$clFinish = loader.apply("clFinish"); + HANDLE$clFinish = RawFunctionLoader.link(SEGMENT$clFinish, Descriptors.DESCRIPTOR$clFinish); + SEGMENT$clEnqueueReadBuffer = loader.apply("clEnqueueReadBuffer"); + HANDLE$clEnqueueReadBuffer = RawFunctionLoader.linkWithOptions(SEGMENT$clEnqueueReadBuffer, Descriptors.DESCRIPTOR$clEnqueueReadBuffer,Linker.Option.critical(true)); + SEGMENT$clEnqueueReadBufferRect = loader.apply("clEnqueueReadBufferRect"); + HANDLE$clEnqueueReadBufferRect = RawFunctionLoader.linkWithOptions(SEGMENT$clEnqueueReadBufferRect, Descriptors.DESCRIPTOR$clEnqueueReadBufferRect,Linker.Option.critical(true)); + SEGMENT$clEnqueueWriteBuffer = loader.apply("clEnqueueWriteBuffer"); + HANDLE$clEnqueueWriteBuffer = RawFunctionLoader.linkWithOptions(SEGMENT$clEnqueueWriteBuffer, Descriptors.DESCRIPTOR$clEnqueueWriteBuffer,Linker.Option.critical(true)); + SEGMENT$clEnqueueWriteBufferRect = loader.apply("clEnqueueWriteBufferRect"); + HANDLE$clEnqueueWriteBufferRect = RawFunctionLoader.linkWithOptions(SEGMENT$clEnqueueWriteBufferRect, Descriptors.DESCRIPTOR$clEnqueueWriteBufferRect,Linker.Option.critical(true)); + SEGMENT$clEnqueueFillBuffer = loader.apply("clEnqueueFillBuffer"); + HANDLE$clEnqueueFillBuffer = RawFunctionLoader.link(SEGMENT$clEnqueueFillBuffer, Descriptors.DESCRIPTOR$clEnqueueFillBuffer); + SEGMENT$clEnqueueCopyBuffer = loader.apply("clEnqueueCopyBuffer"); + HANDLE$clEnqueueCopyBuffer = RawFunctionLoader.link(SEGMENT$clEnqueueCopyBuffer, Descriptors.DESCRIPTOR$clEnqueueCopyBuffer); + SEGMENT$clEnqueueCopyBufferRect = loader.apply("clEnqueueCopyBufferRect"); + HANDLE$clEnqueueCopyBufferRect = RawFunctionLoader.link(SEGMENT$clEnqueueCopyBufferRect, Descriptors.DESCRIPTOR$clEnqueueCopyBufferRect); + SEGMENT$clEnqueueReadImage = loader.apply("clEnqueueReadImage"); + HANDLE$clEnqueueReadImage = RawFunctionLoader.link(SEGMENT$clEnqueueReadImage, Descriptors.DESCRIPTOR$clEnqueueReadImage); + SEGMENT$clEnqueueWriteImage = loader.apply("clEnqueueWriteImage"); + HANDLE$clEnqueueWriteImage = RawFunctionLoader.link(SEGMENT$clEnqueueWriteImage, Descriptors.DESCRIPTOR$clEnqueueWriteImage); + SEGMENT$clEnqueueFillImage = loader.apply("clEnqueueFillImage"); + HANDLE$clEnqueueFillImage = RawFunctionLoader.link(SEGMENT$clEnqueueFillImage, Descriptors.DESCRIPTOR$clEnqueueFillImage); + SEGMENT$clEnqueueCopyImage = loader.apply("clEnqueueCopyImage"); + HANDLE$clEnqueueCopyImage = RawFunctionLoader.link(SEGMENT$clEnqueueCopyImage, Descriptors.DESCRIPTOR$clEnqueueCopyImage); + SEGMENT$clEnqueueCopyImageToBuffer = loader.apply("clEnqueueCopyImageToBuffer"); + HANDLE$clEnqueueCopyImageToBuffer = RawFunctionLoader.link(SEGMENT$clEnqueueCopyImageToBuffer, Descriptors.DESCRIPTOR$clEnqueueCopyImageToBuffer); + SEGMENT$clEnqueueCopyBufferToImage = loader.apply("clEnqueueCopyBufferToImage"); + HANDLE$clEnqueueCopyBufferToImage = RawFunctionLoader.link(SEGMENT$clEnqueueCopyBufferToImage, Descriptors.DESCRIPTOR$clEnqueueCopyBufferToImage); + SEGMENT$clEnqueueMapBuffer = loader.apply("clEnqueueMapBuffer"); + HANDLE$clEnqueueMapBuffer = RawFunctionLoader.link(SEGMENT$clEnqueueMapBuffer, Descriptors.DESCRIPTOR$clEnqueueMapBuffer); + SEGMENT$clEnqueueMapImage = loader.apply("clEnqueueMapImage"); + HANDLE$clEnqueueMapImage = RawFunctionLoader.link(SEGMENT$clEnqueueMapImage, Descriptors.DESCRIPTOR$clEnqueueMapImage); + SEGMENT$clEnqueueUnmapMemObject = loader.apply("clEnqueueUnmapMemObject"); + HANDLE$clEnqueueUnmapMemObject = RawFunctionLoader.link(SEGMENT$clEnqueueUnmapMemObject, Descriptors.DESCRIPTOR$clEnqueueUnmapMemObject); + SEGMENT$clEnqueueMigrateMemObjects = loader.apply("clEnqueueMigrateMemObjects"); + HANDLE$clEnqueueMigrateMemObjects = RawFunctionLoader.link(SEGMENT$clEnqueueMigrateMemObjects, Descriptors.DESCRIPTOR$clEnqueueMigrateMemObjects); + SEGMENT$clEnqueueNDRangeKernel = loader.apply("clEnqueueNDRangeKernel"); + HANDLE$clEnqueueNDRangeKernel = RawFunctionLoader.link(SEGMENT$clEnqueueNDRangeKernel, Descriptors.DESCRIPTOR$clEnqueueNDRangeKernel); + SEGMENT$clEnqueueNativeKernel = loader.apply("clEnqueueNativeKernel"); + HANDLE$clEnqueueNativeKernel = RawFunctionLoader.link(SEGMENT$clEnqueueNativeKernel, Descriptors.DESCRIPTOR$clEnqueueNativeKernel); + SEGMENT$clEnqueueMarkerWithWaitList = loader.apply("clEnqueueMarkerWithWaitList"); + HANDLE$clEnqueueMarkerWithWaitList = RawFunctionLoader.link(SEGMENT$clEnqueueMarkerWithWaitList, Descriptors.DESCRIPTOR$clEnqueueMarkerWithWaitList); + SEGMENT$clEnqueueBarrierWithWaitList = loader.apply("clEnqueueBarrierWithWaitList"); + HANDLE$clEnqueueBarrierWithWaitList = RawFunctionLoader.link(SEGMENT$clEnqueueBarrierWithWaitList, Descriptors.DESCRIPTOR$clEnqueueBarrierWithWaitList); + SEGMENT$clEnqueueSVMFree = loader.apply("clEnqueueSVMFree"); + HANDLE$clEnqueueSVMFree = RawFunctionLoader.link(SEGMENT$clEnqueueSVMFree, Descriptors.DESCRIPTOR$clEnqueueSVMFree); + SEGMENT$clEnqueueSVMMemcpy = loader.apply("clEnqueueSVMMemcpy"); + HANDLE$clEnqueueSVMMemcpy = RawFunctionLoader.link(SEGMENT$clEnqueueSVMMemcpy, Descriptors.DESCRIPTOR$clEnqueueSVMMemcpy); + SEGMENT$clEnqueueSVMMemFill = loader.apply("clEnqueueSVMMemFill"); + HANDLE$clEnqueueSVMMemFill = RawFunctionLoader.link(SEGMENT$clEnqueueSVMMemFill, Descriptors.DESCRIPTOR$clEnqueueSVMMemFill); + SEGMENT$clEnqueueSVMMap = loader.apply("clEnqueueSVMMap"); + HANDLE$clEnqueueSVMMap = RawFunctionLoader.link(SEGMENT$clEnqueueSVMMap, Descriptors.DESCRIPTOR$clEnqueueSVMMap); + SEGMENT$clEnqueueSVMUnmap = loader.apply("clEnqueueSVMUnmap"); + HANDLE$clEnqueueSVMUnmap = RawFunctionLoader.link(SEGMENT$clEnqueueSVMUnmap, Descriptors.DESCRIPTOR$clEnqueueSVMUnmap); + SEGMENT$clEnqueueSVMMigrateMem = loader.apply("clEnqueueSVMMigrateMem"); + HANDLE$clEnqueueSVMMigrateMem = RawFunctionLoader.link(SEGMENT$clEnqueueSVMMigrateMem, Descriptors.DESCRIPTOR$clEnqueueSVMMigrateMem); + SEGMENT$clGetExtensionFunctionAddressForPlatform = loader.apply("clGetExtensionFunctionAddressForPlatform"); + HANDLE$clGetExtensionFunctionAddressForPlatform = RawFunctionLoader.link(SEGMENT$clGetExtensionFunctionAddressForPlatform, Descriptors.DESCRIPTOR$clGetExtensionFunctionAddressForPlatform); + SEGMENT$clSetCommandQueueProperty = loader.apply("clSetCommandQueueProperty"); + HANDLE$clSetCommandQueueProperty = RawFunctionLoader.link(SEGMENT$clSetCommandQueueProperty, Descriptors.DESCRIPTOR$clSetCommandQueueProperty); + SEGMENT$clCreateImage2D = loader.apply("clCreateImage2D"); + HANDLE$clCreateImage2D = RawFunctionLoader.link(SEGMENT$clCreateImage2D, Descriptors.DESCRIPTOR$clCreateImage2D); + SEGMENT$clCreateImage3D = loader.apply("clCreateImage3D"); + HANDLE$clCreateImage3D = RawFunctionLoader.link(SEGMENT$clCreateImage3D, Descriptors.DESCRIPTOR$clCreateImage3D); + SEGMENT$clEnqueueMarker = loader.apply("clEnqueueMarker"); + HANDLE$clEnqueueMarker = RawFunctionLoader.link(SEGMENT$clEnqueueMarker, Descriptors.DESCRIPTOR$clEnqueueMarker); + SEGMENT$clEnqueueWaitForEvents = loader.apply("clEnqueueWaitForEvents"); + HANDLE$clEnqueueWaitForEvents = RawFunctionLoader.link(SEGMENT$clEnqueueWaitForEvents, Descriptors.DESCRIPTOR$clEnqueueWaitForEvents); + SEGMENT$clEnqueueBarrier = loader.apply("clEnqueueBarrier"); + HANDLE$clEnqueueBarrier = RawFunctionLoader.link(SEGMENT$clEnqueueBarrier, Descriptors.DESCRIPTOR$clEnqueueBarrier); + SEGMENT$clUnloadCompiler = loader.apply("clUnloadCompiler"); + HANDLE$clUnloadCompiler = RawFunctionLoader.link(SEGMENT$clUnloadCompiler, Descriptors.DESCRIPTOR$clUnloadCompiler); + SEGMENT$clGetExtensionFunctionAddress = loader.apply("clGetExtensionFunctionAddress"); + HANDLE$clGetExtensionFunctionAddress = RawFunctionLoader.link(SEGMENT$clGetExtensionFunctionAddress, Descriptors.DESCRIPTOR$clGetExtensionFunctionAddress); + SEGMENT$clCreateCommandQueue = loader.apply("clCreateCommandQueue"); + HANDLE$clCreateCommandQueue = RawFunctionLoader.link(SEGMENT$clCreateCommandQueue, Descriptors.DESCRIPTOR$clCreateCommandQueue); + SEGMENT$clCreateSampler = loader.apply("clCreateSampler"); + HANDLE$clCreateSampler = RawFunctionLoader.link(SEGMENT$clCreateSampler, Descriptors.DESCRIPTOR$clCreateSampler); + SEGMENT$clEnqueueTask = loader.apply("clEnqueueTask"); + HANDLE$clEnqueueTask = RawFunctionLoader.link(SEGMENT$clEnqueueTask, Descriptors.DESCRIPTOR$clEnqueueTask); + SEGMENT$clGetLayerInfo = loader.apply("clGetLayerInfo"); + HANDLE$clGetLayerInfo = RawFunctionLoader.link(SEGMENT$clGetLayerInfo, Descriptors.DESCRIPTOR$clGetLayerInfo); + SEGMENT$clInitLayer = loader.apply("clInitLayer"); + HANDLE$clInitLayer = RawFunctionLoader.link(SEGMENT$clInitLayer, Descriptors.DESCRIPTOR$clInitLayer); + SEGMENT$clGetICDLoaderInfoOCLICD = loader.apply("clGetICDLoaderInfoOCLICD"); + HANDLE$clGetICDLoaderInfoOCLICD = RawFunctionLoader.link(SEGMENT$clGetICDLoaderInfoOCLICD, Descriptors.DESCRIPTOR$clGetICDLoaderInfoOCLICD); + SEGMENT$clGetSupportedGLTextureFormatsINTEL = loader.apply("clGetSupportedGLTextureFormatsINTEL"); + HANDLE$clGetSupportedGLTextureFormatsINTEL = RawFunctionLoader.link(SEGMENT$clGetSupportedGLTextureFormatsINTEL, Descriptors.DESCRIPTOR$clGetSupportedGLTextureFormatsINTEL); + SEGMENT$clGetSupportedDX9MediaSurfaceFormatsINTEL = loader.apply("clGetSupportedDX9MediaSurfaceFormatsINTEL"); + HANDLE$clGetSupportedDX9MediaSurfaceFormatsINTEL = RawFunctionLoader.link(SEGMENT$clGetSupportedDX9MediaSurfaceFormatsINTEL, Descriptors.DESCRIPTOR$clGetSupportedDX9MediaSurfaceFormatsINTEL); + SEGMENT$clGetSupportedD3D10TextureFormatsINTEL = loader.apply("clGetSupportedD3D10TextureFormatsINTEL"); + HANDLE$clGetSupportedD3D10TextureFormatsINTEL = RawFunctionLoader.link(SEGMENT$clGetSupportedD3D10TextureFormatsINTEL, Descriptors.DESCRIPTOR$clGetSupportedD3D10TextureFormatsINTEL); + SEGMENT$clGetSupportedD3D11TextureFormatsINTEL = loader.apply("clGetSupportedD3D11TextureFormatsINTEL"); + HANDLE$clGetSupportedD3D11TextureFormatsINTEL = RawFunctionLoader.link(SEGMENT$clGetSupportedD3D11TextureFormatsINTEL, Descriptors.DESCRIPTOR$clGetSupportedD3D11TextureFormatsINTEL); + SEGMENT$clGetSupportedVA_APIMediaSurfaceFormatsINTEL = loader.apply("clGetSupportedVA_APIMediaSurfaceFormatsINTEL"); + HANDLE$clGetSupportedVA_APIMediaSurfaceFormatsINTEL = RawFunctionLoader.link(SEGMENT$clGetSupportedVA_APIMediaSurfaceFormatsINTEL, Descriptors.DESCRIPTOR$clGetSupportedVA_APIMediaSurfaceFormatsINTEL); + SEGMENT$clEnqueueReadHostPipeINTEL = loader.apply("clEnqueueReadHostPipeINTEL"); + HANDLE$clEnqueueReadHostPipeINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueReadHostPipeINTEL, Descriptors.DESCRIPTOR$clEnqueueReadHostPipeINTEL); + SEGMENT$clEnqueueWriteHostPipeINTEL = loader.apply("clEnqueueWriteHostPipeINTEL"); + HANDLE$clEnqueueWriteHostPipeINTEL = RawFunctionLoader.link(SEGMENT$clEnqueueWriteHostPipeINTEL, Descriptors.DESCRIPTOR$clEnqueueWriteHostPipeINTEL); + SEGMENT$clGetImageRequirementsInfoEXT = loader.apply("clGetImageRequirementsInfoEXT"); + HANDLE$clGetImageRequirementsInfoEXT = RawFunctionLoader.link(SEGMENT$clGetImageRequirementsInfoEXT, Descriptors.DESCRIPTOR$clGetImageRequirementsInfoEXT); + SEGMENT$clCancelCommandsIMG = loader.apply("clCancelCommandsIMG"); + HANDLE$clCancelCommandsIMG = RawFunctionLoader.link(SEGMENT$clCancelCommandsIMG, Descriptors.DESCRIPTOR$clCancelCommandsIMG); + SEGMENT$clSetPerfHintQCOM = loader.apply("clSetPerfHintQCOM"); + HANDLE$clSetPerfHintQCOM = RawFunctionLoader.link(SEGMENT$clSetPerfHintQCOM, Descriptors.DESCRIPTOR$clSetPerfHintQCOM); + } + + // region command wrappers + + /// @see clGetDeviceIDsFromD3D10KHR + public @NativeType("cl_int") int getDeviceIDsFromD3D10KHR( + CLPlatformId platform, + @NativeType("cl_d3d10_device_source_khr") @Unsigned int d3d_device_source, + @Pointer(comment="void*") MemorySegment d3d_object, + @NativeType("cl_d3d10_device_set_khr") @Unsigned int d3d_device_set, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLDeviceId.Ptr devices, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_devices + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceIDsFromD3D10KHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + (MemorySegment) (devices != null ? devices.segment() : MemorySegment.NULL), + (MemorySegment) (num_devices != null ? num_devices.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromD3D10BufferKHR + public CLMem createFromD3D10BufferKHR( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + PointerPtr resource, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromD3D10BufferKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (resource != null ? resource.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromD3D10Texture2DKHR + public CLMem createFromD3D10Texture2DKHR( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + PointerPtr resource, + @NativeType("UINT") @Unsigned int subresource, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromD3D10Texture2DKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (resource != null ? resource.segment() : MemorySegment.NULL), + subresource, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromD3D10Texture3DKHR + public CLMem createFromD3D10Texture3DKHR( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + PointerPtr resource, + @NativeType("UINT") @Unsigned int subresource, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromD3D10Texture3DKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (resource != null ? resource.segment() : MemorySegment.NULL), + subresource, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireD3D10ObjectsKHR + public @NativeType("cl_int") int enqueueAcquireD3D10ObjectsKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireD3D10ObjectsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseD3D10ObjectsKHR + public @NativeType("cl_int") int enqueueReleaseD3D10ObjectsKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseD3D10ObjectsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetDeviceIDsFromD3D11KHR + public @NativeType("cl_int") int getDeviceIDsFromD3D11KHR( + CLPlatformId platform, + @NativeType("cl_d3d11_device_source_khr") @Unsigned int d3d_device_source, + @Pointer(comment="void*") MemorySegment d3d_object, + @NativeType("cl_d3d11_device_set_khr") @Unsigned int d3d_device_set, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLDeviceId.Ptr devices, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_devices + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceIDsFromD3D11KHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + d3d_device_source, + d3d_object, + d3d_device_set, + num_entries, + (MemorySegment) (devices != null ? devices.segment() : MemorySegment.NULL), + (MemorySegment) (num_devices != null ? num_devices.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromD3D11BufferKHR + public CLMem createFromD3D11BufferKHR( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + PointerPtr resource, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromD3D11BufferKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (resource != null ? resource.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromD3D11Texture2DKHR + public CLMem createFromD3D11Texture2DKHR( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + PointerPtr resource, + @NativeType("UINT") @Unsigned int subresource, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromD3D11Texture2DKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (resource != null ? resource.segment() : MemorySegment.NULL), + subresource, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromD3D11Texture3DKHR + public CLMem createFromD3D11Texture3DKHR( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + PointerPtr resource, + @NativeType("UINT") @Unsigned int subresource, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromD3D11Texture3DKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (resource != null ? resource.segment() : MemorySegment.NULL), + subresource, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireD3D11ObjectsKHR + public @NativeType("cl_int") int enqueueAcquireD3D11ObjectsKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireD3D11ObjectsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseD3D11ObjectsKHR + public @NativeType("cl_int") int enqueueReleaseD3D11ObjectsKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseD3D11ObjectsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetDeviceIDsFromDX9MediaAdapterKHR + public @NativeType("cl_int") int getDeviceIDsFromDX9MediaAdapterKHR( + CLPlatformId platform, + @NativeType("cl_uint") @Unsigned int num_media_adapters, + @Pointer(comment="cl_dx9_media_adapter_type_khr") @Unsigned IntPtr media_adapter_type, + @Pointer(comment="void*") MemorySegment media_adapters, + @NativeType("cl_dx9_media_adapter_set_khr") @Unsigned int media_adapter_set, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLDeviceId.Ptr devices, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_devices + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceIDsFromDX9MediaAdapterKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + num_media_adapters, + (MemorySegment) (media_adapter_type != null ? media_adapter_type.segment() : MemorySegment.NULL), + media_adapters, + media_adapter_set, + num_entries, + (MemorySegment) (devices != null ? devices.segment() : MemorySegment.NULL), + (MemorySegment) (num_devices != null ? num_devices.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromDX9MediaSurfaceKHR + public CLMem createFromDX9MediaSurfaceKHR( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_dx9_media_adapter_type_khr") @Unsigned int adapter_type, + @Pointer(comment="void*") MemorySegment surface_info, + @NativeType("cl_uint") @Unsigned int plane, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromDX9MediaSurfaceKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + adapter_type, + surface_info, + plane, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireDX9MediaSurfacesKHR + public @NativeType("cl_int") int enqueueAcquireDX9MediaSurfacesKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireDX9MediaSurfacesKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseDX9MediaSurfacesKHR + public @NativeType("cl_int") int enqueueReleaseDX9MediaSurfacesKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseDX9MediaSurfacesKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetDeviceIDsFromDX9INTEL + public @NativeType("cl_int") int getDeviceIDsFromDX9INTEL( + CLPlatformId platform, + @NativeType("cl_dx9_device_source_intel") @Unsigned int dx9_device_source, + @Pointer(comment="void*") MemorySegment dx9_object, + @NativeType("cl_dx9_device_set_intel") @Unsigned int dx9_device_set, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLDeviceId.Ptr devices, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_devices + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceIDsFromDX9INTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + dx9_device_source, + dx9_object, + dx9_device_set, + num_entries, + (MemorySegment) (devices != null ? devices.segment() : MemorySegment.NULL), + (MemorySegment) (num_devices != null ? num_devices.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromDX9MediaSurfaceINTEL + public CLMem createFromDX9MediaSurfaceINTEL( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + PointerPtr resource, + @Pointer(comment="HANDLE") MemorySegment sharedHandle, + @NativeType("UINT") @Unsigned int plane, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromDX9MediaSurfaceINTEL); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (resource != null ? resource.segment() : MemorySegment.NULL), + sharedHandle, + plane, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireDX9ObjectsINTEL + public @NativeType("cl_int") int enqueueAcquireDX9ObjectsINTEL( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireDX9ObjectsINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseDX9ObjectsINTEL + public @NativeType("cl_int") int enqueueReleaseDX9ObjectsINTEL( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseDX9ObjectsINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateEventFromEGLSyncKHR + public CLEvent createEventFromEGLSyncKHR( + CLContext context, + @Pointer(comment="CLeglSyncKHR") MemorySegment sync, + @Pointer(comment="CLeglDisplayKHR") MemorySegment display, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateEventFromEGLSyncKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + sync, + display, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLEvent(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromEGLImageKHR + public CLMem createFromEGLImageKHR( + CLContext context, + @Pointer(comment="CLeglDisplayKHR") MemorySegment egldisplay, + @Pointer(comment="CLeglImageKHR") MemorySegment eglimage, + @NativeType("cl_mem_flags") @Unsigned long flags, + @Pointer(comment="cl_egl_image_properties_khr") PointerPtr properties, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromEGLImageKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + egldisplay, + eglimage, + flags, + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireEGLObjectsKHR + public @NativeType("cl_int") int enqueueAcquireEGLObjectsKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireEGLObjectsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseEGLObjectsKHR + public @NativeType("cl_int") int enqueueReleaseEGLObjectsKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseEGLObjectsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clLogMessagesToSystemLogAPPLE + public void logMessagesToSystemLogAPPLE( + BytePtr errstr, + @Pointer(comment="void*") MemorySegment private_info, + long cb, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clLogMessagesToSystemLogAPPLE); + try { + hFunction.invokeExact( + (MemorySegment) (errstr != null ? errstr.segment() : MemorySegment.NULL), + private_info, + MemorySegment.ofAddress(cb), + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clLogMessagesToStdoutAPPLE + public void logMessagesToStdoutAPPLE( + BytePtr errstr, + @Pointer(comment="void*") MemorySegment private_info, + long cb, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clLogMessagesToStdoutAPPLE); + try { + hFunction.invokeExact( + (MemorySegment) (errstr != null ? errstr.segment() : MemorySegment.NULL), + private_info, + MemorySegment.ofAddress(cb), + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clLogMessagesToStderrAPPLE + public void logMessagesToStderrAPPLE( + BytePtr errstr, + @Pointer(comment="void*") MemorySegment private_info, + long cb, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clLogMessagesToStderrAPPLE); + try { + hFunction.invokeExact( + (MemorySegment) (errstr != null ? errstr.segment() : MemorySegment.NULL), + private_info, + MemorySegment.ofAddress(cb), + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clIcdGetPlatformIDsKHR + public @NativeType("cl_int") int icdGetPlatformIDsKHR( + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLPlatformId.Ptr platforms, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_platforms + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clIcdGetPlatformIDsKHR); + try { + return (int) hFunction.invokeExact( + num_entries, + (MemorySegment) (platforms != null ? platforms.segment() : MemorySegment.NULL), + (MemorySegment) (num_platforms != null ? num_platforms.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clIcdGetFunctionAddressForPlatformKHR + public @Pointer(comment="void*") MemorySegment icdGetFunctionAddressForPlatformKHR( + CLPlatformId platform, + BytePtr func_name + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clIcdGetFunctionAddressForPlatformKHR); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + (MemorySegment) (func_name != null ? func_name.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clIcdSetPlatformDispatchDataKHR + public @NativeType("cl_int") int icdSetPlatformDispatchDataKHR( + CLPlatformId platform, + @Pointer(comment="void*") MemorySegment dispatch_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clIcdSetPlatformDispatchDataKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + dispatch_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateProgramWithILKHR + public CLProgram createProgramWithILKHR( + CLContext context, + @Pointer(comment="void*") MemorySegment il, + long length, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateProgramWithILKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + il, + MemorySegment.ofAddress(length), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLProgram(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clTerminateContextKHR + public @NativeType("cl_int") int terminateContextKHR( + CLContext context + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clTerminateContextKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateCommandQueueWithPropertiesKHR + public CLCommandQueue createCommandQueueWithPropertiesKHR( + CLContext context, + CLDeviceId device, + @Pointer(comment="cl_queue_properties_khr") @Unsigned LongPtr properties, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateCommandQueueWithPropertiesKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLCommandQueue(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseDeviceEXT + public @NativeType("cl_int") int releaseDeviceEXT( + CLDeviceId device + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseDeviceEXT); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainDeviceEXT + public @NativeType("cl_int") int retainDeviceEXT( + CLDeviceId device + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainDeviceEXT); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateSubDevicesEXT + public @NativeType("cl_int") int createSubDevicesEXT( + CLDeviceId in_device, + @Pointer(comment="cl_device_partition_property_ext") @Unsigned LongPtr properties, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLDeviceId.Ptr out_devices, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_devices + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateSubDevicesEXT); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (in_device != null ? in_device.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + num_entries, + (MemorySegment) (out_devices != null ? out_devices.segment() : MemorySegment.NULL), + (MemorySegment) (num_devices != null ? num_devices.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMigrateMemObjectEXT + public @NativeType("cl_int") int enqueueMigrateMemObjectEXT( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_mem_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_mem_migration_flags_ext") @Unsigned long flags, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMigrateMemObjectEXT); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_mem_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + flags, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetDeviceImageInfoQCOM + public @NativeType("cl_int") int getDeviceImageInfoQCOM( + CLDeviceId device, + long imageWidth, + long imageHeight, + @Pointer CLImageFormat image_format, + @NativeType("cl_image_pitch_info_qcom") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceImageInfoQCOM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(imageWidth), + MemorySegment.ofAddress(imageHeight), + (MemorySegment) (image_format != null ? image_format.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireGrallocObjectsIMG + public @NativeType("cl_int") int enqueueAcquireGrallocObjectsIMG( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireGrallocObjectsIMG); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueGenerateMipmapIMG + public @NativeType("cl_int") int enqueueGenerateMipmapIMG( + CLCommandQueue command_queue, + CLMem src_image, + CLMem dst_image, + @NativeType("cl_mipmap_filter_mode_img") @Unsigned int mipmap_filter_mode, + PointerPtr array_region, + PointerPtr mip_region, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueGenerateMipmapIMG); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (src_image != null ? src_image.segment() : MemorySegment.NULL), + (MemorySegment) (dst_image != null ? dst_image.segment() : MemorySegment.NULL), + mipmap_filter_mode, + (MemorySegment) (array_region != null ? array_region.segment() : MemorySegment.NULL), + (MemorySegment) (mip_region != null ? mip_region.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseGrallocObjectsIMG + public @NativeType("cl_int") int enqueueReleaseGrallocObjectsIMG( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseGrallocObjectsIMG); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetKernelSubGroupInfoKHR + public @NativeType("cl_int") int getKernelSubGroupInfoKHR( + CLKernel in_kernel, + CLDeviceId in_device, + @NativeType("cl_kernel_sub_group_info") @Unsigned int paramName, + long input_value_size, + @Pointer(comment="void*") MemorySegment input_value, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetKernelSubGroupInfoKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (in_kernel != null ? in_kernel.segment() : MemorySegment.NULL), + (MemorySegment) (in_device != null ? in_device.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(input_value_size), + input_value, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetKernelSuggestedLocalWorkSizeKHR + public @NativeType("cl_int") int getKernelSuggestedLocalWorkSizeKHR( + CLCommandQueue command_queue, + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int workDim, + PointerPtr globalWorkOffset, + PointerPtr globalWorkSize, + PointerPtr suggested_local_work_size + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetKernelSuggestedLocalWorkSizeKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + workDim, + (MemorySegment) (globalWorkOffset != null ? globalWorkOffset.segment() : MemorySegment.NULL), + (MemorySegment) (globalWorkSize != null ? globalWorkSize.segment() : MemorySegment.NULL), + (MemorySegment) (suggested_local_work_size != null ? suggested_local_work_size.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateSemaphoreWithPropertiesKHR + public CLSemaphoreKhr createSemaphoreWithPropertiesKHR( + CLContext context, + @Pointer(comment="cl_semaphore_properties_khr") @Unsigned LongPtr sema_props, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateSemaphoreWithPropertiesKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (sema_props != null ? sema_props.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLSemaphoreKhr(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueWaitSemaphoresKHR + public @NativeType("cl_int") int enqueueWaitSemaphoresKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_sema_objects, + @Pointer CLSemaphoreKhr.Ptr sema_objects, + @Pointer(comment="cl_semaphore_payload_khr") @Unsigned LongPtr sema_payload_list, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueWaitSemaphoresKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_sema_objects, + (MemorySegment) (sema_objects != null ? sema_objects.segment() : MemorySegment.NULL), + (MemorySegment) (sema_payload_list != null ? sema_payload_list.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSignalSemaphoresKHR + public @NativeType("cl_int") int enqueueSignalSemaphoresKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_sema_objects, + @Pointer CLSemaphoreKhr.Ptr sema_objects, + @Pointer(comment="cl_semaphore_payload_khr") @Unsigned LongPtr sema_payload_list, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSignalSemaphoresKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_sema_objects, + (MemorySegment) (sema_objects != null ? sema_objects.segment() : MemorySegment.NULL), + (MemorySegment) (sema_payload_list != null ? sema_payload_list.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSemaphoreInfoKHR + public @NativeType("cl_int") int getSemaphoreInfoKHR( + CLSemaphoreKhr sema_object, + @NativeType("cl_semaphore_info_khr") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSemaphoreInfoKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (sema_object != null ? sema_object.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseSemaphoreKHR + public @NativeType("cl_int") int releaseSemaphoreKHR( + CLSemaphoreKhr sema_object + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseSemaphoreKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (sema_object != null ? sema_object.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainSemaphoreKHR + public @NativeType("cl_int") int retainSemaphoreKHR( + CLSemaphoreKhr sema_object + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainSemaphoreKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (sema_object != null ? sema_object.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSemaphoreHandleForTypeKHR + public @NativeType("cl_int") int getSemaphoreHandleForTypeKHR( + CLSemaphoreKhr sema_object, + CLDeviceId device, + @NativeType("cl_external_semaphore_handle_type_khr") @Unsigned int handle_type, + long handle_size, + @Pointer(comment="void*") MemorySegment handle_ptr, + PointerPtr handle_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSemaphoreHandleForTypeKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (sema_object != null ? sema_object.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + handle_type, + MemorySegment.ofAddress(handle_size), + handle_ptr, + (MemorySegment) (handle_size_ret != null ? handle_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReImportSemaphoreSyncFdKHR + public @NativeType("cl_int") int reImportSemaphoreSyncFdKHR( + CLSemaphoreKhr sema_object, + @Pointer(comment="cl_semaphore_reimport_properties_khr") @Unsigned LongPtr reimport_props, + int fd + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReImportSemaphoreSyncFdKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (sema_object != null ? sema_object.segment() : MemorySegment.NULL), + (MemorySegment) (reimport_props != null ? reimport_props.segment() : MemorySegment.NULL), + fd + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireExternalMemObjectsKHR + public @NativeType("cl_int") int enqueueAcquireExternalMemObjectsKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_mem_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireExternalMemObjectsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_mem_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseExternalMemObjectsKHR + public @NativeType("cl_int") int enqueueReleaseExternalMemObjectsKHR( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_mem_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseExternalMemObjectsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_mem_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clImportMemoryARM + public CLMem importMemoryARM( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @Pointer(comment="cl_import_properties_arm") PointerPtr properties, + @Pointer(comment="void*") MemorySegment memory, + long size, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clImportMemoryARM); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + memory, + MemorySegment.ofAddress(size), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSVMAllocARM + public @Pointer(comment="void*") MemorySegment SVMAllocARM( + CLContext context, + @NativeType("cl_svm_mem_flags_arm") @Unsigned long flags, + long size, + @NativeType("cl_uint") @Unsigned int alignment + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSVMAllocARM); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + MemorySegment.ofAddress(size), + alignment + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSVMFreeARM + public void SVMFreeARM( + CLContext context, + @Pointer(comment="void*") MemorySegment svm_pointer + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSVMFreeARM); + try { + hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + svm_pointer + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMFreeARM + public @NativeType("cl_int") int enqueueSVMFreeARM( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_svm_pointers, + @Pointer(comment="void*") MemorySegment svm_pointers, + @Pointer(comment="pfn_free_func_0") MemorySegment pfn_free_func, + @Pointer(comment="void*") MemorySegment user_data, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMFreeARM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_svm_pointers, + svm_pointers, + pfn_free_func, + user_data, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int enqueueSVMFreeARM( + Arena arena, + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_svm_pointers, + @Pointer(comment="void*") MemorySegment svm_pointers, + Ipfn_free_func_0 pfn_free_func, + @Pointer(comment="void*") MemorySegment user_data, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + return enqueueSVMFreeARM( + command_queue, + num_svm_pointers, + svm_pointers, + Ipfn_free_func_0.ofNative(arena, pfn_free_func), + user_data, + num_events_in_wait_list, + event_wait_list, + event + ); + } + + public @NativeType("cl_int") int enqueueSVMFreeARM( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_svm_pointers, + @Pointer(comment="void*") MemorySegment svm_pointers, + Ipfn_free_func_0 pfn_free_func, + @Pointer(comment="void*") MemorySegment user_data, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + return enqueueSVMFreeARM( + Arena.global(), + command_queue, + num_svm_pointers, + svm_pointers, + pfn_free_func, + user_data, + num_events_in_wait_list, + event_wait_list, + event + ); + } + + /// @see clEnqueueSVMMemcpyARM + public @NativeType("cl_int") int enqueueSVMMemcpyARM( + CLCommandQueue command_queue, + @NativeType("cl_bool") @Unsigned int blocking_copy, + @Pointer(comment="void*") MemorySegment dst_ptr, + @Pointer(comment="void*") MemorySegment src_ptr, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMMemcpyARM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + blocking_copy, + dst_ptr, + src_ptr, + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMMemFillARM + public @NativeType("cl_int") int enqueueSVMMemFillARM( + CLCommandQueue command_queue, + @Pointer(comment="void*") MemorySegment svm_ptr, + @Pointer(comment="void*") MemorySegment pattern, + long pattern_size, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMMemFillARM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + svm_ptr, + pattern, + MemorySegment.ofAddress(pattern_size), + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMMapARM + public @NativeType("cl_int") int enqueueSVMMapARM( + CLCommandQueue command_queue, + @NativeType("cl_bool") @Unsigned int blocking_map, + @NativeType("cl_map_flags") @Unsigned long flags, + @Pointer(comment="void*") MemorySegment svm_ptr, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMMapARM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + blocking_map, + flags, + svm_ptr, + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMUnmapARM + public @NativeType("cl_int") int enqueueSVMUnmapARM( + CLCommandQueue command_queue, + @Pointer(comment="void*") MemorySegment svm_ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMUnmapARM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + svm_ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetKernelArgSVMPointerARM + public @NativeType("cl_int") int setKernelArgSVMPointerARM( + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int argIndex, + @Pointer(comment="void*") MemorySegment argValue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetKernelArgSVMPointerARM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + argIndex, + argValue + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetKernelExecInfoARM + public @NativeType("cl_int") int setKernelExecInfoARM( + CLKernel kernel, + @NativeType("cl_kernel_exec_info_arm") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetKernelExecInfoARM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateAcceleratorINTEL + public CLAcceleratorIntel createAcceleratorINTEL( + CLContext context, + @NativeType("cl_accelerator_type_intel") @Unsigned int accelerator_type, + long descriptor_size, + @Pointer(comment="void*") MemorySegment descriptor, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateAcceleratorINTEL); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + accelerator_type, + MemorySegment.ofAddress(descriptor_size), + descriptor, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLAcceleratorIntel(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetAcceleratorInfoINTEL + public @NativeType("cl_int") int getAcceleratorInfoINTEL( + CLAcceleratorIntel accelerator, + @NativeType("cl_accelerator_info_intel") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetAcceleratorInfoINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (accelerator != null ? accelerator.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainAcceleratorINTEL + public @NativeType("cl_int") int retainAcceleratorINTEL( + CLAcceleratorIntel accelerator + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainAcceleratorINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (accelerator != null ? accelerator.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseAcceleratorINTEL + public @NativeType("cl_int") int releaseAcceleratorINTEL( + CLAcceleratorIntel accelerator + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseAcceleratorINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (accelerator != null ? accelerator.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateEventFromGLsyncKHR + public CLEvent createEventFromGLsyncKHR( + CLContext context, + CLGLsync sync, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateEventFromGLsyncKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (sync != null ? sync.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLEvent(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetGLContextInfoKHR + public @NativeType("cl_int") int getGLContextInfoKHR( + @Pointer(comment="cl_context_properties") PointerPtr properties, + @NativeType("cl_gl_context_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetGLContextInfoKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromGLBuffer + public CLMem createFromGLBuffer( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_GLuint") @Unsigned int bufobj, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromGLBuffer); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + bufobj, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromGLTexture + public CLMem createFromGLTexture( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_GLenum") @Unsigned int target, + @NativeType("cl_GLint") int miplevel, + @NativeType("cl_GLuint") @Unsigned int texture, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromGLTexture); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + target, + miplevel, + texture, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromGLRenderbuffer + public CLMem createFromGLRenderbuffer( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_GLuint") @Unsigned int renderbuffer, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromGLRenderbuffer); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + renderbuffer, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetGLObjectInfo + public @NativeType("cl_int") int getGLObjectInfo( + CLMem memobj, + @Pointer(comment="cl_gl_object_type") @Unsigned IntPtr gl_object_type, + @Pointer(comment="cl_GLuint") @Unsigned IntPtr gl_object_name + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetGLObjectInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (memobj != null ? memobj.segment() : MemorySegment.NULL), + (MemorySegment) (gl_object_type != null ? gl_object_type.segment() : MemorySegment.NULL), + (MemorySegment) (gl_object_name != null ? gl_object_name.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetGLTextureInfo + public @NativeType("cl_int") int getGLTextureInfo( + CLMem memobj, + @NativeType("cl_gl_texture_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetGLTextureInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (memobj != null ? memobj.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireGLObjects + public @NativeType("cl_int") int enqueueAcquireGLObjects( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireGLObjects); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseGLObjects + public @NativeType("cl_int") int enqueueReleaseGLObjects( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseGLObjects); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromGLTexture2D + public CLMem createFromGLTexture2D( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_GLenum") @Unsigned int target, + @NativeType("cl_GLint") int miplevel, + @NativeType("cl_GLuint") @Unsigned int texture, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromGLTexture2D); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + target, + miplevel, + texture, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromGLTexture3D + public CLMem createFromGLTexture3D( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_GLenum") @Unsigned int target, + @NativeType("cl_GLint") int miplevel, + @NativeType("cl_GLuint") @Unsigned int texture, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromGLTexture3D); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + target, + miplevel, + texture, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetDeviceIDsFromVA_APIMediaAdapterINTEL + public @NativeType("cl_int") int getDeviceIDsFromVA_APIMediaAdapterINTEL( + CLPlatformId platform, + @NativeType("cl_va_api_device_source_intel") @Unsigned int media_adapter_type, + @Pointer(comment="void*") MemorySegment media_adapter, + @NativeType("cl_va_api_device_set_intel") @Unsigned int media_adapter_set, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLDeviceId.Ptr devices, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_devices + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceIDsFromVA_APIMediaAdapterINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + media_adapter_type, + media_adapter, + media_adapter_set, + num_entries, + (MemorySegment) (devices != null ? devices.segment() : MemorySegment.NULL), + (MemorySegment) (num_devices != null ? num_devices.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateFromVA_APIMediaSurfaceINTEL + public CLMem createFromVA_APIMediaSurfaceINTEL( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @Pointer(comment="VASurfaceID") @Unsigned IntPtr surface, + @NativeType("cl_uint") @Unsigned int plane, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateFromVA_APIMediaSurfaceINTEL); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (surface != null ? surface.segment() : MemorySegment.NULL), + plane, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueAcquireVA_APIMediaSurfacesINTEL + public @NativeType("cl_int") int enqueueAcquireVA_APIMediaSurfacesINTEL( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueAcquireVA_APIMediaSurfacesINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReleaseVA_APIMediaSurfacesINTEL + public @NativeType("cl_int") int enqueueReleaseVA_APIMediaSurfacesINTEL( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReleaseVA_APIMediaSurfacesINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clHostMemAllocINTEL + public @Pointer(comment="void*") MemorySegment hostMemAllocINTEL( + CLContext context, + @Pointer(comment="cl_mem_properties_intel") @Unsigned LongPtr properties, + long size, + @NativeType("cl_uint") @Unsigned int alignment, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clHostMemAllocINTEL); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(size), + alignment, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clDeviceMemAllocINTEL + public @Pointer(comment="void*") MemorySegment deviceMemAllocINTEL( + CLContext context, + CLDeviceId device, + @Pointer(comment="cl_mem_properties_intel") @Unsigned LongPtr properties, + long size, + @NativeType("cl_uint") @Unsigned int alignment, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clDeviceMemAllocINTEL); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(size), + alignment, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSharedMemAllocINTEL + public @Pointer(comment="void*") MemorySegment sharedMemAllocINTEL( + CLContext context, + CLDeviceId device, + @Pointer(comment="cl_mem_properties_intel") @Unsigned LongPtr properties, + long size, + @NativeType("cl_uint") @Unsigned int alignment, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSharedMemAllocINTEL); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(size), + alignment, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clMemFreeINTEL + public @NativeType("cl_int") int memFreeINTEL( + CLContext context, + @Pointer(comment="void*") MemorySegment ptr + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clMemFreeINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + ptr + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clMemBlockingFreeINTEL + public @NativeType("cl_int") int memBlockingFreeINTEL( + CLContext context, + @Pointer(comment="void*") MemorySegment ptr + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clMemBlockingFreeINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + ptr + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetMemAllocInfoINTEL + public @NativeType("cl_int") int getMemAllocInfoINTEL( + CLContext context, + @Pointer(comment="void*") MemorySegment ptr, + @NativeType("cl_mem_info_intel") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetMemAllocInfoINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + ptr, + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetKernelArgMemPointerINTEL + public @NativeType("cl_int") int setKernelArgMemPointerINTEL( + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int argIndex, + @Pointer(comment="void*") MemorySegment argValue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetKernelArgMemPointerINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + argIndex, + argValue + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMemsetINTEL + public @NativeType("cl_int") int enqueueMemsetINTEL( + CLCommandQueue command_queue, + @Pointer(comment="void*") MemorySegment dst_ptr, + @NativeType("cl_int") int value, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMemsetINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + dst_ptr, + value, + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMemFillINTEL + public @NativeType("cl_int") int enqueueMemFillINTEL( + CLCommandQueue command_queue, + @Pointer(comment="void*") MemorySegment dst_ptr, + @Pointer(comment="void*") MemorySegment pattern, + long pattern_size, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMemFillINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + dst_ptr, + pattern, + MemorySegment.ofAddress(pattern_size), + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMemcpyINTEL + public @NativeType("cl_int") int enqueueMemcpyINTEL( + CLCommandQueue command_queue, + @NativeType("cl_bool") @Unsigned int blocking, + @Pointer(comment="void*") MemorySegment dst_ptr, + @Pointer(comment="void*") MemorySegment src_ptr, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMemcpyINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + blocking, + dst_ptr, + src_ptr, + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMigrateMemINTEL + public @NativeType("cl_int") int enqueueMigrateMemINTEL( + CLCommandQueue command_queue, + @Pointer(comment="void*") MemorySegment ptr, + long size, + @NativeType("cl_mem_migration_flags") @Unsigned long flags, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMigrateMemINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + ptr, + MemorySegment.ofAddress(size), + flags, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMemAdviseINTEL + public @NativeType("cl_int") int enqueueMemAdviseINTEL( + CLCommandQueue command_queue, + @Pointer(comment="void*") MemorySegment ptr, + long size, + @NativeType("cl_mem_advice_intel") @Unsigned int advice, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMemAdviseINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + ptr, + MemorySegment.ofAddress(size), + advice, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateBufferWithPropertiesINTEL + public CLMem createBufferWithPropertiesINTEL( + CLContext context, + @Pointer(comment="cl_mem_properties_intel") @Unsigned LongPtr properties, + @NativeType("cl_mem_flags") @Unsigned long flags, + long size, + @Pointer(comment="void*") MemorySegment host_ptr, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateBufferWithPropertiesINTEL); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + flags, + MemorySegment.ofAddress(size), + host_ptr, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateCommandBufferKHR + public CLCommandBufferKhr createCommandBufferKHR( + @NativeType("cl_uint") @Unsigned int num_queues, + @Pointer CLCommandQueue.Ptr queues, + @Pointer(comment="cl_command_buffer_properties_khr") @Unsigned LongPtr properties, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateCommandBufferKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + num_queues, + (MemorySegment) (queues != null ? queues.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLCommandBufferKhr(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clFinalizeCommandBufferKHR + public @NativeType("cl_int") int finalizeCommandBufferKHR( + CLCommandBufferKhr command_buffer + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clFinalizeCommandBufferKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainCommandBufferKHR + public @NativeType("cl_int") int retainCommandBufferKHR( + CLCommandBufferKhr command_buffer + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainCommandBufferKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseCommandBufferKHR + public @NativeType("cl_int") int releaseCommandBufferKHR( + CLCommandBufferKhr command_buffer + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseCommandBufferKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueCommandBufferKHR + public @NativeType("cl_int") int enqueueCommandBufferKHR( + @NativeType("cl_uint") @Unsigned int num_queues, + @Pointer CLCommandQueue.Ptr queues, + CLCommandBufferKhr command_buffer, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueCommandBufferKHR); + try { + return (int) hFunction.invokeExact( + num_queues, + (MemorySegment) (queues != null ? queues.segment() : MemorySegment.NULL), + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandBarrierWithWaitListKHR + public @NativeType("cl_int") int commandBarrierWithWaitListKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandBarrierWithWaitListKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandCopyBufferKHR + public @NativeType("cl_int") int commandCopyBufferKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + CLMem src_buffer, + CLMem dst_buffer, + long src_offset, + long dst_offset, + long size, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandCopyBufferKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (src_buffer != null ? src_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (dst_buffer != null ? dst_buffer.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(src_offset), + MemorySegment.ofAddress(dst_offset), + MemorySegment.ofAddress(size), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandCopyBufferRectKHR + public @NativeType("cl_int") int commandCopyBufferRectKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + CLMem src_buffer, + CLMem dst_buffer, + PointerPtr src_origin, + PointerPtr dst_origin, + PointerPtr region, + long src_row_pitch, + long src_slice_pitch, + long dst_row_pitch, + long dst_slice_pitch, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandCopyBufferRectKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (src_buffer != null ? src_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (dst_buffer != null ? dst_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (src_origin != null ? src_origin.segment() : MemorySegment.NULL), + (MemorySegment) (dst_origin != null ? dst_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(src_row_pitch), + MemorySegment.ofAddress(src_slice_pitch), + MemorySegment.ofAddress(dst_row_pitch), + MemorySegment.ofAddress(dst_slice_pitch), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandCopyBufferToImageKHR + public @NativeType("cl_int") int commandCopyBufferToImageKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + CLMem src_buffer, + CLMem dst_image, + long src_offset, + PointerPtr dst_origin, + PointerPtr region, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandCopyBufferToImageKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (src_buffer != null ? src_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (dst_image != null ? dst_image.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(src_offset), + (MemorySegment) (dst_origin != null ? dst_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandCopyImageKHR + public @NativeType("cl_int") int commandCopyImageKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + CLMem src_image, + CLMem dst_image, + PointerPtr src_origin, + PointerPtr dst_origin, + PointerPtr region, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandCopyImageKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (src_image != null ? src_image.segment() : MemorySegment.NULL), + (MemorySegment) (dst_image != null ? dst_image.segment() : MemorySegment.NULL), + (MemorySegment) (src_origin != null ? src_origin.segment() : MemorySegment.NULL), + (MemorySegment) (dst_origin != null ? dst_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandCopyImageToBufferKHR + public @NativeType("cl_int") int commandCopyImageToBufferKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + CLMem src_image, + CLMem dst_buffer, + PointerPtr src_origin, + PointerPtr region, + long dst_offset, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandCopyImageToBufferKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (src_image != null ? src_image.segment() : MemorySegment.NULL), + (MemorySegment) (dst_buffer != null ? dst_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (src_origin != null ? src_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(dst_offset), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandFillBufferKHR + public @NativeType("cl_int") int commandFillBufferKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + CLMem buffer, + @Pointer(comment="void*") MemorySegment pattern, + long pattern_size, + long offset, + long size, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandFillBufferKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + pattern, + MemorySegment.ofAddress(pattern_size), + MemorySegment.ofAddress(offset), + MemorySegment.ofAddress(size), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandFillImageKHR + public @NativeType("cl_int") int commandFillImageKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + CLMem image, + @Pointer(comment="void*") MemorySegment fill_color, + PointerPtr origin, + PointerPtr region, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandFillImageKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (image != null ? image.segment() : MemorySegment.NULL), + fill_color, + (MemorySegment) (origin != null ? origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandNDRangeKernelKHR + public @NativeType("cl_int") int commandNDRangeKernelKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int workDim, + PointerPtr globalWorkOffset, + PointerPtr globalWorkSize, + PointerPtr localWorkSize, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandNDRangeKernelKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + workDim, + (MemorySegment) (globalWorkOffset != null ? globalWorkOffset.segment() : MemorySegment.NULL), + (MemorySegment) (globalWorkSize != null ? globalWorkSize.segment() : MemorySegment.NULL), + (MemorySegment) (localWorkSize != null ? localWorkSize.segment() : MemorySegment.NULL), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandSVMMemcpyKHR + public @NativeType("cl_int") int commandSVMMemcpyKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + @Pointer(comment="void*") MemorySegment dst_ptr, + @Pointer(comment="void*") MemorySegment src_ptr, + long size, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandSVMMemcpyKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + dst_ptr, + src_ptr, + MemorySegment.ofAddress(size), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCommandSVMMemFillKHR + public @NativeType("cl_int") int commandSVMMemFillKHR( + CLCommandBufferKhr command_buffer, + CLCommandQueue command_queue, + @Pointer(comment="cl_command_properties_khr") @Unsigned LongPtr properties, + @Pointer(comment="void*") MemorySegment svm_ptr, + @Pointer(comment="void*") MemorySegment pattern, + long pattern_size, + long size, + @NativeType("cl_uint") @Unsigned int num_sync_points_in_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point_wait_list, + @Pointer(comment="cl_sync_point_khr") @Unsigned IntPtr sync_point, + @Pointer CLMutableCommandKhr.Ptr mutable_handle + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCommandSVMMemFillKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + svm_ptr, + pattern, + MemorySegment.ofAddress(pattern_size), + MemorySegment.ofAddress(size), + num_sync_points_in_wait_list, + (MemorySegment) (sync_point_wait_list != null ? sync_point_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (sync_point != null ? sync_point.segment() : MemorySegment.NULL), + (MemorySegment) (mutable_handle != null ? mutable_handle.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetCommandBufferInfoKHR + public @NativeType("cl_int") int getCommandBufferInfoKHR( + CLCommandBufferKhr command_buffer, + @NativeType("cl_command_buffer_info_khr") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetCommandBufferInfoKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clUpdateMutableCommandsKHR + public @NativeType("cl_int") int updateMutableCommandsKHR( + CLCommandBufferKhr command_buffer, + @NativeType("cl_uint") @Unsigned int num_configs, + @Pointer(comment="cl_command_buffer_update_type_khr") @Unsigned IntPtr config_types, + PointerPtr configs + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clUpdateMutableCommandsKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + num_configs, + (MemorySegment) (config_types != null ? config_types.segment() : MemorySegment.NULL), + (MemorySegment) (configs != null ? configs.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetMutableCommandInfoKHR + public @NativeType("cl_int") int getMutableCommandInfoKHR( + CLMutableCommandKhr command, + @NativeType("cl_mutable_command_info_khr") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetMutableCommandInfoKHR); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command != null ? command.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRemapCommandBufferKHR + public CLCommandBufferKhr remapCommandBufferKHR( + CLCommandBufferKhr command_buffer, + @NativeType("cl_bool") @Unsigned int automatic, + @NativeType("cl_uint") @Unsigned int num_queues, + @Pointer CLCommandQueue.Ptr queues, + @NativeType("cl_uint") @Unsigned int num_handles, + @Pointer CLMutableCommandKhr.Ptr handles, + @Pointer CLMutableCommandKhr.Ptr handles_ret, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRemapCommandBufferKHR); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (command_buffer != null ? command_buffer.segment() : MemorySegment.NULL), + automatic, + num_queues, + (MemorySegment) (queues != null ? queues.segment() : MemorySegment.NULL), + num_handles, + (MemorySegment) (handles != null ? handles.segment() : MemorySegment.NULL), + (MemorySegment) (handles_ret != null ? handles_ret.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLCommandBufferKhr(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetContentSizeBufferPoCL + public @NativeType("cl_int") int setContentSizeBufferPoCL( + CLMem buffer, + CLMem content_size_buffer + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetContentSizeBufferPoCL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + (MemorySegment) (content_size_buffer != null ? content_size_buffer.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetPlatformIDs + public @NativeType("cl_int") int getPlatformIDs( + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLPlatformId.Ptr platforms, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_platforms + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetPlatformIDs); + try { + return (int) hFunction.invokeExact( + num_entries, + (MemorySegment) (platforms != null ? platforms.segment() : MemorySegment.NULL), + (MemorySegment) (num_platforms != null ? num_platforms.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetPlatformInfo + public @NativeType("cl_int") int getPlatformInfo( + CLPlatformId platform, + @NativeType("cl_platform_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetPlatformInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetDeviceIDs + public @NativeType("cl_int") int getDeviceIDs( + CLPlatformId platform, + @NativeType("cl_device_type") @Unsigned long device_type, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLDeviceId.Ptr devices, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_devices + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceIDs); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + device_type, + num_entries, + (MemorySegment) (devices != null ? devices.segment() : MemorySegment.NULL), + (MemorySegment) (num_devices != null ? num_devices.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetDeviceInfo + public @NativeType("cl_int") int getDeviceInfo( + CLDeviceId device, + @NativeType("cl_device_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateSubDevices + public @NativeType("cl_int") int createSubDevices( + CLDeviceId in_device, + @Pointer(comment="cl_device_partition_property") PointerPtr properties, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr out_devices, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_devices_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateSubDevices); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (in_device != null ? in_device.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + num_devices, + (MemorySegment) (out_devices != null ? out_devices.segment() : MemorySegment.NULL), + (MemorySegment) (num_devices_ret != null ? num_devices_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainDevice + public @NativeType("cl_int") int retainDevice( + CLDeviceId device + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainDevice); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseDevice + public @NativeType("cl_int") int releaseDevice( + CLDeviceId device + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseDevice); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetDefaultDeviceCommandQueue + public @NativeType("cl_int") int setDefaultDeviceCommandQueue( + CLContext context, + CLDeviceId device, + CLCommandQueue command_queue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetDefaultDeviceCommandQueue); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetDeviceAndHostTimer + public @NativeType("cl_int") int getDeviceAndHostTimer( + CLDeviceId device, + @Pointer(comment="cl_ulong") @Unsigned LongPtr device_timestamp, + @Pointer(comment="cl_ulong") @Unsigned LongPtr host_timestamp + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetDeviceAndHostTimer); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + (MemorySegment) (device_timestamp != null ? device_timestamp.segment() : MemorySegment.NULL), + (MemorySegment) (host_timestamp != null ? host_timestamp.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetHostTimer + public @NativeType("cl_int") int getHostTimer( + CLDeviceId device, + @Pointer(comment="cl_ulong") @Unsigned LongPtr host_timestamp + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetHostTimer); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + (MemorySegment) (host_timestamp != null ? host_timestamp.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateContext + public CLContext createContext( + @Pointer(comment="cl_context_properties") PointerPtr properties, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr devices, + @Pointer(comment="pfn_notify_0") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateContext); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + num_devices, + (MemorySegment) (devices != null ? devices.segment() : MemorySegment.NULL), + pfn_notify, + user_data, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLContext(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public CLContext createContext( + Arena arena, + @Pointer(comment="cl_context_properties") PointerPtr properties, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr devices, + Ipfn_notify_0 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + return createContext( + properties, + num_devices, + devices, + Ipfn_notify_0.ofNative(arena, pfn_notify), + user_data, + errcode_ret + ); + } + + public CLContext createContext( + @Pointer(comment="cl_context_properties") PointerPtr properties, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr devices, + Ipfn_notify_0 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + return createContext( + Arena.global(), + properties, + num_devices, + devices, + pfn_notify, + user_data, + errcode_ret + ); + } + + /// @see clCreateContextFromType + public CLContext createContextFromType( + @Pointer(comment="cl_context_properties") PointerPtr properties, + @NativeType("cl_device_type") @Unsigned long device_type, + @Pointer(comment="pfn_notify_1") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateContextFromType); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + device_type, + pfn_notify, + user_data, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLContext(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public CLContext createContextFromType( + Arena arena, + @Pointer(comment="cl_context_properties") PointerPtr properties, + @NativeType("cl_device_type") @Unsigned long device_type, + Ipfn_notify_1 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + return createContextFromType( + properties, + device_type, + Ipfn_notify_1.ofNative(arena, pfn_notify), + user_data, + errcode_ret + ); + } + + public CLContext createContextFromType( + @Pointer(comment="cl_context_properties") PointerPtr properties, + @NativeType("cl_device_type") @Unsigned long device_type, + Ipfn_notify_1 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + return createContextFromType( + Arena.global(), + properties, + device_type, + pfn_notify, + user_data, + errcode_ret + ); + } + + /// @see clRetainContext + public @NativeType("cl_int") int retainContext( + CLContext context + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainContext); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseContext + public @NativeType("cl_int") int releaseContext( + CLContext context + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseContext); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetContextInfo + public @NativeType("cl_int") int getContextInfo( + CLContext context, + @NativeType("cl_context_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetContextInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetContextDestructorCallback + public @NativeType("cl_int") int setContextDestructorCallback( + CLContext context, + @Pointer(comment="pfn_notify_2") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetContextDestructorCallback); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + pfn_notify, + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int setContextDestructorCallback( + Arena arena, + CLContext context, + Ipfn_notify_2 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setContextDestructorCallback( + context, + Ipfn_notify_2.ofNative(arena, pfn_notify), + user_data + ); + } + + public @NativeType("cl_int") int setContextDestructorCallback( + CLContext context, + Ipfn_notify_2 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setContextDestructorCallback( + Arena.global(), + context, + pfn_notify, + user_data + ); + } + + /// @see clCreateCommandQueueWithProperties + public CLCommandQueue createCommandQueueWithProperties( + CLContext context, + CLDeviceId device, + @Pointer(comment="cl_queue_properties") @Unsigned LongPtr properties, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateCommandQueueWithProperties); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLCommandQueue(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainCommandQueue + public @NativeType("cl_int") int retainCommandQueue( + CLCommandQueue command_queue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainCommandQueue); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseCommandQueue + public @NativeType("cl_int") int releaseCommandQueue( + CLCommandQueue command_queue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseCommandQueue); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetCommandQueueInfo + public @NativeType("cl_int") int getCommandQueueInfo( + CLCommandQueue command_queue, + @NativeType("cl_command_queue_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetCommandQueueInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateBuffer + public CLMem createBuffer( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + long size, + @Pointer(comment="void*") MemorySegment host_ptr, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateBuffer); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + MemorySegment.ofAddress(size), + host_ptr, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateBufferWithProperties + public CLMem createBufferWithProperties( + CLContext context, + @Pointer(comment="cl_mem_properties") @Unsigned LongPtr properties, + @NativeType("cl_mem_flags") @Unsigned long flags, + long size, + @Pointer(comment="void*") MemorySegment host_ptr, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateBufferWithProperties); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + flags, + MemorySegment.ofAddress(size), + host_ptr, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateSubBuffer + public CLMem createSubBuffer( + CLMem buffer, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_buffer_create_type") @Unsigned int buffer_create_type, + @Pointer(comment="void*") MemorySegment buffer_create_info, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateSubBuffer); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + flags, + buffer_create_type, + buffer_create_info, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateImage + public CLMem createImage( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @Pointer CLImageFormat image_format, + @Pointer CLImageDesc image_desc, + @Pointer(comment="void*") MemorySegment host_ptr, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateImage); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (image_format != null ? image_format.segment() : MemorySegment.NULL), + (MemorySegment) (image_desc != null ? image_desc.segment() : MemorySegment.NULL), + host_ptr, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateImageWithProperties + public CLMem createImageWithProperties( + CLContext context, + @Pointer(comment="cl_mem_properties") @Unsigned LongPtr properties, + @NativeType("cl_mem_flags") @Unsigned long flags, + @Pointer CLImageFormat image_format, + @Pointer CLImageDesc image_desc, + @Pointer(comment="void*") MemorySegment host_ptr, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateImageWithProperties); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (image_format != null ? image_format.segment() : MemorySegment.NULL), + (MemorySegment) (image_desc != null ? image_desc.segment() : MemorySegment.NULL), + host_ptr, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreatePipe + public CLMem createPipe( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_uint") @Unsigned int pipe_packet_size, + @NativeType("cl_uint") @Unsigned int pipe_max_packets, + @Pointer(comment="cl_pipe_properties") PointerPtr properties, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreatePipe); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + pipe_packet_size, + pipe_max_packets, + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainMemObject + public @NativeType("cl_int") int retainMemObject( + CLMem memobj + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainMemObject); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (memobj != null ? memobj.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseMemObject + public @NativeType("cl_int") int releaseMemObject( + CLMem memobj + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseMemObject); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (memobj != null ? memobj.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSupportedImageFormats + public @NativeType("cl_int") int getSupportedImageFormats( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_mem_object_type") @Unsigned int imageType, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer CLImageFormat image_formats, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_image_formats + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSupportedImageFormats); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + imageType, + num_entries, + (MemorySegment) (image_formats != null ? image_formats.segment() : MemorySegment.NULL), + (MemorySegment) (num_image_formats != null ? num_image_formats.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetMemObjectInfo + public @NativeType("cl_int") int getMemObjectInfo( + CLMem memobj, + @NativeType("cl_mem_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetMemObjectInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (memobj != null ? memobj.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetImageInfo + public @NativeType("cl_int") int getImageInfo( + CLMem image, + @NativeType("cl_image_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetImageInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (image != null ? image.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetPipeInfo + public @NativeType("cl_int") int getPipeInfo( + CLMem pipe, + @NativeType("cl_pipe_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetPipeInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (pipe != null ? pipe.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetMemObjectDestructorCallback + public @NativeType("cl_int") int setMemObjectDestructorCallback( + CLMem memobj, + @Pointer(comment="pfn_notify_3") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetMemObjectDestructorCallback); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (memobj != null ? memobj.segment() : MemorySegment.NULL), + pfn_notify, + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int setMemObjectDestructorCallback( + Arena arena, + CLMem memobj, + Ipfn_notify_3 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setMemObjectDestructorCallback( + memobj, + Ipfn_notify_3.ofNative(arena, pfn_notify), + user_data + ); + } + + public @NativeType("cl_int") int setMemObjectDestructorCallback( + CLMem memobj, + Ipfn_notify_3 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setMemObjectDestructorCallback( + Arena.global(), + memobj, + pfn_notify, + user_data + ); + } + + /// @see clSetMemObjectDestructorAPPLE + public @NativeType("cl_int") int setMemObjectDestructorAPPLE( + CLMem memobj, + @Pointer(comment="pfn_notify_4") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetMemObjectDestructorAPPLE); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (memobj != null ? memobj.segment() : MemorySegment.NULL), + pfn_notify, + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int setMemObjectDestructorAPPLE( + Arena arena, + CLMem memobj, + Ipfn_notify_4 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setMemObjectDestructorAPPLE( + memobj, + Ipfn_notify_4.ofNative(arena, pfn_notify), + user_data + ); + } + + public @NativeType("cl_int") int setMemObjectDestructorAPPLE( + CLMem memobj, + Ipfn_notify_4 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setMemObjectDestructorAPPLE( + Arena.global(), + memobj, + pfn_notify, + user_data + ); + } + + /// @see clSVMAlloc + public @Pointer(comment="void*") MemorySegment SVMAlloc( + CLContext context, + @NativeType("cl_svm_mem_flags") @Unsigned long flags, + long size, + @NativeType("cl_uint") @Unsigned int alignment + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSVMAlloc); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + MemorySegment.ofAddress(size), + alignment + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSVMFree + public void SVMFree( + CLContext context, + @Pointer(comment="void*") MemorySegment svm_pointer + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSVMFree); + try { + hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + svm_pointer + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateSamplerWithProperties + public CLSampler createSamplerWithProperties( + CLContext context, + @Pointer(comment="cl_sampler_properties") @Unsigned LongPtr sampler_properties, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateSamplerWithProperties); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (sampler_properties != null ? sampler_properties.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLSampler(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainSampler + public @NativeType("cl_int") int retainSampler( + CLSampler sampler + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainSampler); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (sampler != null ? sampler.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseSampler + public @NativeType("cl_int") int releaseSampler( + CLSampler sampler + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseSampler); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (sampler != null ? sampler.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSamplerInfo + public @NativeType("cl_int") int getSamplerInfo( + CLSampler sampler, + @NativeType("cl_sampler_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSamplerInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (sampler != null ? sampler.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateProgramWithSource + public CLProgram createProgramWithSource( + CLContext context, + @NativeType("cl_uint") @Unsigned int count, + PointerPtr strings, + PointerPtr lengths, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateProgramWithSource); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + count, + (MemorySegment) (strings != null ? strings.segment() : MemorySegment.NULL), + (MemorySegment) (lengths != null ? lengths.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLProgram(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateProgramWithBinary + public CLProgram createProgramWithBinary( + CLContext context, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + PointerPtr lengths, + PointerPtr binaries, + @Pointer(comment="cl_int") IntPtr binary_status, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateProgramWithBinary); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + num_devices, + (MemorySegment) (device_list != null ? device_list.segment() : MemorySegment.NULL), + (MemorySegment) (lengths != null ? lengths.segment() : MemorySegment.NULL), + (MemorySegment) (binaries != null ? binaries.segment() : MemorySegment.NULL), + (MemorySegment) (binary_status != null ? binary_status.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLProgram(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateProgramWithBuiltInKernels + public CLProgram createProgramWithBuiltInKernels( + CLContext context, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr kernel_names, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateProgramWithBuiltInKernels); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + num_devices, + (MemorySegment) (device_list != null ? device_list.segment() : MemorySegment.NULL), + (MemorySegment) (kernel_names != null ? kernel_names.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLProgram(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateProgramWithIL + public CLProgram createProgramWithIL( + CLContext context, + @Pointer(comment="void*") MemorySegment il, + long length, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateProgramWithIL); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + il, + MemorySegment.ofAddress(length), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLProgram(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainProgram + public @NativeType("cl_int") int retainProgram( + CLProgram program + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainProgram); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseProgram + public @NativeType("cl_int") int releaseProgram( + CLProgram program + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseProgram); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clBuildProgram + public @NativeType("cl_int") int buildProgram( + CLProgram program, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + @Pointer(comment="pfn_notify_5") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clBuildProgram); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + num_devices, + (MemorySegment) (device_list != null ? device_list.segment() : MemorySegment.NULL), + (MemorySegment) (options != null ? options.segment() : MemorySegment.NULL), + pfn_notify, + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int buildProgram( + Arena arena, + CLProgram program, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + Ipfn_notify_5 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return buildProgram( + program, + num_devices, + device_list, + options, + Ipfn_notify_5.ofNative(arena, pfn_notify), + user_data + ); + } + + public @NativeType("cl_int") int buildProgram( + CLProgram program, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + Ipfn_notify_5 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return buildProgram( + Arena.global(), + program, + num_devices, + device_list, + options, + pfn_notify, + user_data + ); + } + + /// @see clCompileProgram + public @NativeType("cl_int") int compileProgram( + CLProgram program, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + @NativeType("cl_uint") @Unsigned int num_input_headers, + @Pointer CLProgram.Ptr input_headers, + PointerPtr header_include_names, + @Pointer(comment="pfn_notify_6") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCompileProgram); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + num_devices, + (MemorySegment) (device_list != null ? device_list.segment() : MemorySegment.NULL), + (MemorySegment) (options != null ? options.segment() : MemorySegment.NULL), + num_input_headers, + (MemorySegment) (input_headers != null ? input_headers.segment() : MemorySegment.NULL), + (MemorySegment) (header_include_names != null ? header_include_names.segment() : MemorySegment.NULL), + pfn_notify, + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int compileProgram( + Arena arena, + CLProgram program, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + @NativeType("cl_uint") @Unsigned int num_input_headers, + @Pointer CLProgram.Ptr input_headers, + PointerPtr header_include_names, + Ipfn_notify_6 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return compileProgram( + program, + num_devices, + device_list, + options, + num_input_headers, + input_headers, + header_include_names, + Ipfn_notify_6.ofNative(arena, pfn_notify), + user_data + ); + } + + public @NativeType("cl_int") int compileProgram( + CLProgram program, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + @NativeType("cl_uint") @Unsigned int num_input_headers, + @Pointer CLProgram.Ptr input_headers, + PointerPtr header_include_names, + Ipfn_notify_6 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return compileProgram( + Arena.global(), + program, + num_devices, + device_list, + options, + num_input_headers, + input_headers, + header_include_names, + pfn_notify, + user_data + ); + } + + /// @see clLinkProgram + public CLProgram linkProgram( + CLContext context, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + @NativeType("cl_uint") @Unsigned int num_input_programs, + @Pointer CLProgram.Ptr input_programs, + @Pointer(comment="pfn_notify_7") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clLinkProgram); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + num_devices, + (MemorySegment) (device_list != null ? device_list.segment() : MemorySegment.NULL), + (MemorySegment) (options != null ? options.segment() : MemorySegment.NULL), + num_input_programs, + (MemorySegment) (input_programs != null ? input_programs.segment() : MemorySegment.NULL), + pfn_notify, + user_data, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLProgram(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public CLProgram linkProgram( + Arena arena, + CLContext context, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + @NativeType("cl_uint") @Unsigned int num_input_programs, + @Pointer CLProgram.Ptr input_programs, + Ipfn_notify_7 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + return linkProgram( + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + Ipfn_notify_7.ofNative(arena, pfn_notify), + user_data, + errcode_ret + ); + } + + public CLProgram linkProgram( + CLContext context, + @NativeType("cl_uint") @Unsigned int num_devices, + @Pointer CLDeviceId.Ptr device_list, + BytePtr options, + @NativeType("cl_uint") @Unsigned int num_input_programs, + @Pointer CLProgram.Ptr input_programs, + Ipfn_notify_7 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + return linkProgram( + Arena.global(), + context, + num_devices, + device_list, + options, + num_input_programs, + input_programs, + pfn_notify, + user_data, + errcode_ret + ); + } + + /// @see clSetProgramReleaseCallback + public @NativeType("cl_int") int setProgramReleaseCallback( + CLProgram program, + @Pointer(comment="pfn_notify_8") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetProgramReleaseCallback); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + pfn_notify, + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int setProgramReleaseCallback( + Arena arena, + CLProgram program, + Ipfn_notify_8 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setProgramReleaseCallback( + program, + Ipfn_notify_8.ofNative(arena, pfn_notify), + user_data + ); + } + + public @NativeType("cl_int") int setProgramReleaseCallback( + CLProgram program, + Ipfn_notify_8 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setProgramReleaseCallback( + Arena.global(), + program, + pfn_notify, + user_data + ); + } + + /// @see clSetProgramSpecializationConstant + public @NativeType("cl_int") int setProgramSpecializationConstant( + CLProgram program, + @NativeType("cl_uint") @Unsigned int spec_id, + long spec_size, + @Pointer(comment="void*") MemorySegment spec_value + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetProgramSpecializationConstant); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + spec_id, + MemorySegment.ofAddress(spec_size), + spec_value + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clUnloadPlatformCompiler + public @NativeType("cl_int") int unloadPlatformCompiler( + CLPlatformId platform + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clUnloadPlatformCompiler); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetProgramInfo + public @NativeType("cl_int") int getProgramInfo( + CLProgram program, + @NativeType("cl_program_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetProgramInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetProgramBuildInfo + public @NativeType("cl_int") int getProgramBuildInfo( + CLProgram program, + CLDeviceId device, + @NativeType("cl_program_build_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetProgramBuildInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateKernel + public CLKernel createKernel( + CLProgram program, + BytePtr kernel_name, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateKernel); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + (MemorySegment) (kernel_name != null ? kernel_name.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLKernel(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateKernelsInProgram + public @NativeType("cl_int") int createKernelsInProgram( + CLProgram program, + @NativeType("cl_uint") @Unsigned int num_kernels, + @Pointer CLKernel.Ptr kernels, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_kernels_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateKernelsInProgram); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + num_kernels, + (MemorySegment) (kernels != null ? kernels.segment() : MemorySegment.NULL), + (MemorySegment) (num_kernels_ret != null ? num_kernels_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCloneKernel + public CLKernel cloneKernel( + CLKernel source_kernel, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCloneKernel); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (source_kernel != null ? source_kernel.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLKernel(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainKernel + public @NativeType("cl_int") int retainKernel( + CLKernel kernel + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainKernel); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseKernel + public @NativeType("cl_int") int releaseKernel( + CLKernel kernel + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseKernel); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetKernelArg + public @NativeType("cl_int") int setKernelArg( + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int argIndex, + long argSize, + @Pointer(comment="void*") MemorySegment argValue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetKernelArg); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + argIndex, + MemorySegment.ofAddress(argSize), + argValue + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetKernelArgSVMPointer + public @NativeType("cl_int") int setKernelArgSVMPointer( + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int argIndex, + @Pointer(comment="void*") MemorySegment argValue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetKernelArgSVMPointer); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + argIndex, + argValue + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetKernelArgDevicePointerEXT + public @NativeType("cl_int") int setKernelArgDevicePointerEXT( + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int argIndex, + @NativeType("cl_mem_device_address_ext") @Unsigned long argValue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetKernelArgDevicePointerEXT); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + argIndex, + argValue + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetKernelExecInfo + public @NativeType("cl_int") int setKernelExecInfo( + CLKernel kernel, + @NativeType("cl_kernel_exec_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetKernelExecInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetKernelInfo + public @NativeType("cl_int") int getKernelInfo( + CLKernel kernel, + @NativeType("cl_kernel_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetKernelInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetKernelArgInfo + public @NativeType("cl_int") int getKernelArgInfo( + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int argIndex, + @NativeType("cl_kernel_arg_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetKernelArgInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + argIndex, + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetKernelWorkGroupInfo + public @NativeType("cl_int") int getKernelWorkGroupInfo( + CLKernel kernel, + CLDeviceId device, + @NativeType("cl_kernel_work_group_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetKernelWorkGroupInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetKernelSubGroupInfo + public @NativeType("cl_int") int getKernelSubGroupInfo( + CLKernel kernel, + CLDeviceId device, + @NativeType("cl_kernel_sub_group_info") @Unsigned int paramName, + long input_value_size, + @Pointer(comment="void*") MemorySegment input_value, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetKernelSubGroupInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(input_value_size), + input_value, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clWaitForEvents + public @NativeType("cl_int") int waitForEvents( + @NativeType("cl_uint") @Unsigned int num_events, + @Pointer CLEvent.Ptr event_list + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clWaitForEvents); + try { + return (int) hFunction.invokeExact( + num_events, + (MemorySegment) (event_list != null ? event_list.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetEventInfo + public @NativeType("cl_int") int getEventInfo( + CLEvent event, + @NativeType("cl_event_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetEventInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateUserEvent + public CLEvent createUserEvent( + CLContext context, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateUserEvent); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLEvent(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clRetainEvent + public @NativeType("cl_int") int retainEvent( + CLEvent event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clRetainEvent); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clReleaseEvent + public @NativeType("cl_int") int releaseEvent( + CLEvent event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clReleaseEvent); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetUserEventStatus + public @NativeType("cl_int") int setUserEventStatus( + CLEvent event, + @NativeType("cl_int") int execution_status + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetUserEventStatus); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL), + execution_status + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetEventCallback + public @NativeType("cl_int") int setEventCallback( + CLEvent event, + @NativeType("cl_int") int command_exec_callback_type, + @Pointer(comment="pfn_notify_9") MemorySegment pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetEventCallback); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL), + command_exec_callback_type, + pfn_notify, + user_data + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int setEventCallback( + Arena arena, + CLEvent event, + @NativeType("cl_int") int command_exec_callback_type, + Ipfn_notify_9 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setEventCallback( + event, + command_exec_callback_type, + Ipfn_notify_9.ofNative(arena, pfn_notify), + user_data + ); + } + + public @NativeType("cl_int") int setEventCallback( + CLEvent event, + @NativeType("cl_int") int command_exec_callback_type, + Ipfn_notify_9 pfn_notify, + @Pointer(comment="void*") MemorySegment user_data + ) { + return setEventCallback( + Arena.global(), + event, + command_exec_callback_type, + pfn_notify, + user_data + ); + } + + /// @see clGetEventProfilingInfo + public @NativeType("cl_int") int getEventProfilingInfo( + CLEvent event, + @NativeType("cl_profiling_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetEventProfilingInfo); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clFlush + public @NativeType("cl_int") int flush( + CLCommandQueue command_queue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clFlush); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clFinish + public @NativeType("cl_int") int finish( + CLCommandQueue command_queue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clFinish); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReadBuffer + public @NativeType("cl_int") int enqueueReadBuffer( + CLCommandQueue command_queue, + CLMem buffer, + @NativeType("cl_bool") @Unsigned int blocking_read, + long offset, + long size, + @Pointer(comment="void*") MemorySegment ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReadBuffer); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + blocking_read, + MemorySegment.ofAddress(offset), + MemorySegment.ofAddress(size), + ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReadBufferRect + public @NativeType("cl_int") int enqueueReadBufferRect( + CLCommandQueue command_queue, + CLMem buffer, + @NativeType("cl_bool") @Unsigned int blocking_read, + PointerPtr buffer_origin, + PointerPtr host_origin, + PointerPtr region, + long buffer_row_pitch, + long buffer_slice_pitch, + long host_row_pitch, + long host_slice_pitch, + @Pointer(comment="void*") MemorySegment ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReadBufferRect); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + blocking_read, + (MemorySegment) (buffer_origin != null ? buffer_origin.segment() : MemorySegment.NULL), + (MemorySegment) (host_origin != null ? host_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(buffer_row_pitch), + MemorySegment.ofAddress(buffer_slice_pitch), + MemorySegment.ofAddress(host_row_pitch), + MemorySegment.ofAddress(host_slice_pitch), + ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueWriteBuffer + public @NativeType("cl_int") int enqueueWriteBuffer( + CLCommandQueue command_queue, + CLMem buffer, + @NativeType("cl_bool") @Unsigned int blocking_write, + long offset, + long size, + @Pointer(comment="void*") MemorySegment ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueWriteBuffer); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + blocking_write, + MemorySegment.ofAddress(offset), + MemorySegment.ofAddress(size), + ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueWriteBufferRect + public @NativeType("cl_int") int enqueueWriteBufferRect( + CLCommandQueue command_queue, + CLMem buffer, + @NativeType("cl_bool") @Unsigned int blocking_write, + PointerPtr buffer_origin, + PointerPtr host_origin, + PointerPtr region, + long buffer_row_pitch, + long buffer_slice_pitch, + long host_row_pitch, + long host_slice_pitch, + @Pointer(comment="void*") MemorySegment ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueWriteBufferRect); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + blocking_write, + (MemorySegment) (buffer_origin != null ? buffer_origin.segment() : MemorySegment.NULL), + (MemorySegment) (host_origin != null ? host_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(buffer_row_pitch), + MemorySegment.ofAddress(buffer_slice_pitch), + MemorySegment.ofAddress(host_row_pitch), + MemorySegment.ofAddress(host_slice_pitch), + ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueFillBuffer + public @NativeType("cl_int") int enqueueFillBuffer( + CLCommandQueue command_queue, + CLMem buffer, + @Pointer(comment="void*") MemorySegment pattern, + long pattern_size, + long offset, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueFillBuffer); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + pattern, + MemorySegment.ofAddress(pattern_size), + MemorySegment.ofAddress(offset), + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueCopyBuffer + public @NativeType("cl_int") int enqueueCopyBuffer( + CLCommandQueue command_queue, + CLMem src_buffer, + CLMem dst_buffer, + long src_offset, + long dst_offset, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueCopyBuffer); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (src_buffer != null ? src_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (dst_buffer != null ? dst_buffer.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(src_offset), + MemorySegment.ofAddress(dst_offset), + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueCopyBufferRect + public @NativeType("cl_int") int enqueueCopyBufferRect( + CLCommandQueue command_queue, + CLMem src_buffer, + CLMem dst_buffer, + PointerPtr src_origin, + PointerPtr dst_origin, + PointerPtr region, + long src_row_pitch, + long src_slice_pitch, + long dst_row_pitch, + long dst_slice_pitch, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueCopyBufferRect); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (src_buffer != null ? src_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (dst_buffer != null ? dst_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (src_origin != null ? src_origin.segment() : MemorySegment.NULL), + (MemorySegment) (dst_origin != null ? dst_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(src_row_pitch), + MemorySegment.ofAddress(src_slice_pitch), + MemorySegment.ofAddress(dst_row_pitch), + MemorySegment.ofAddress(dst_slice_pitch), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReadImage + public @NativeType("cl_int") int enqueueReadImage( + CLCommandQueue command_queue, + CLMem image, + @NativeType("cl_bool") @Unsigned int blocking_read, + PointerPtr origin, + PointerPtr region, + long row_pitch, + long slice_pitch, + @Pointer(comment="void*") MemorySegment ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReadImage); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (image != null ? image.segment() : MemorySegment.NULL), + blocking_read, + (MemorySegment) (origin != null ? origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(row_pitch), + MemorySegment.ofAddress(slice_pitch), + ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueWriteImage + public @NativeType("cl_int") int enqueueWriteImage( + CLCommandQueue command_queue, + CLMem image, + @NativeType("cl_bool") @Unsigned int blocking_write, + PointerPtr origin, + PointerPtr region, + long input_row_pitch, + long input_slice_pitch, + @Pointer(comment="void*") MemorySegment ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueWriteImage); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (image != null ? image.segment() : MemorySegment.NULL), + blocking_write, + (MemorySegment) (origin != null ? origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(input_row_pitch), + MemorySegment.ofAddress(input_slice_pitch), + ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueFillImage + public @NativeType("cl_int") int enqueueFillImage( + CLCommandQueue command_queue, + CLMem image, + @Pointer(comment="void*") MemorySegment fill_color, + PointerPtr origin, + PointerPtr region, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueFillImage); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (image != null ? image.segment() : MemorySegment.NULL), + fill_color, + (MemorySegment) (origin != null ? origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueCopyImage + public @NativeType("cl_int") int enqueueCopyImage( + CLCommandQueue command_queue, + CLMem src_image, + CLMem dst_image, + PointerPtr src_origin, + PointerPtr dst_origin, + PointerPtr region, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueCopyImage); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (src_image != null ? src_image.segment() : MemorySegment.NULL), + (MemorySegment) (dst_image != null ? dst_image.segment() : MemorySegment.NULL), + (MemorySegment) (src_origin != null ? src_origin.segment() : MemorySegment.NULL), + (MemorySegment) (dst_origin != null ? dst_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueCopyImageToBuffer + public @NativeType("cl_int") int enqueueCopyImageToBuffer( + CLCommandQueue command_queue, + CLMem src_image, + CLMem dst_buffer, + PointerPtr src_origin, + PointerPtr region, + long dst_offset, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueCopyImageToBuffer); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (src_image != null ? src_image.segment() : MemorySegment.NULL), + (MemorySegment) (dst_buffer != null ? dst_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (src_origin != null ? src_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(dst_offset), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueCopyBufferToImage + public @NativeType("cl_int") int enqueueCopyBufferToImage( + CLCommandQueue command_queue, + CLMem src_buffer, + CLMem dst_image, + long src_offset, + PointerPtr dst_origin, + PointerPtr region, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueCopyBufferToImage); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (src_buffer != null ? src_buffer.segment() : MemorySegment.NULL), + (MemorySegment) (dst_image != null ? dst_image.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(src_offset), + (MemorySegment) (dst_origin != null ? dst_origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMapBuffer + public @Pointer(comment="void*") MemorySegment enqueueMapBuffer( + CLCommandQueue command_queue, + CLMem buffer, + @NativeType("cl_bool") @Unsigned int blocking_map, + @NativeType("cl_map_flags") @Unsigned long map_flags, + long offset, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMapBuffer); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (buffer != null ? buffer.segment() : MemorySegment.NULL), + blocking_map, + map_flags, + MemorySegment.ofAddress(offset), + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMapImage + public @Pointer(comment="void*") MemorySegment enqueueMapImage( + CLCommandQueue command_queue, + CLMem image, + @NativeType("cl_bool") @Unsigned int blocking_map, + @NativeType("cl_map_flags") @Unsigned long map_flags, + PointerPtr origin, + PointerPtr region, + PointerPtr imageRowPitch, + PointerPtr imageSlicePitch, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMapImage); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (image != null ? image.segment() : MemorySegment.NULL), + blocking_map, + map_flags, + (MemorySegment) (origin != null ? origin.segment() : MemorySegment.NULL), + (MemorySegment) (region != null ? region.segment() : MemorySegment.NULL), + (MemorySegment) (imageRowPitch != null ? imageRowPitch.segment() : MemorySegment.NULL), + (MemorySegment) (imageSlicePitch != null ? imageSlicePitch.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL), + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueUnmapMemObject + public @NativeType("cl_int") int enqueueUnmapMemObject( + CLCommandQueue command_queue, + CLMem memobj, + @Pointer(comment="void*") MemorySegment mapped_ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueUnmapMemObject); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (memobj != null ? memobj.segment() : MemorySegment.NULL), + mapped_ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMigrateMemObjects + public @NativeType("cl_int") int enqueueMigrateMemObjects( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_mem_objects, + @Pointer CLMem.Ptr mem_objects, + @NativeType("cl_mem_migration_flags") @Unsigned long flags, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMigrateMemObjects); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_mem_objects, + (MemorySegment) (mem_objects != null ? mem_objects.segment() : MemorySegment.NULL), + flags, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueNDRangeKernel + public @NativeType("cl_int") int enqueueNDRangeKernel( + CLCommandQueue command_queue, + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int workDim, + PointerPtr globalWorkOffset, + PointerPtr globalWorkSize, + PointerPtr localWorkSize, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueNDRangeKernel); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + workDim, + (MemorySegment) (globalWorkOffset != null ? globalWorkOffset.segment() : MemorySegment.NULL), + (MemorySegment) (globalWorkSize != null ? globalWorkSize.segment() : MemorySegment.NULL), + (MemorySegment) (localWorkSize != null ? localWorkSize.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueNativeKernel + public @NativeType("cl_int") int enqueueNativeKernel( + CLCommandQueue command_queue, + @Pointer(comment="user_func_0") MemorySegment user_func, + @Pointer(comment="void*") MemorySegment args, + long cb_args, + @NativeType("cl_uint") @Unsigned int num_mem_objects, + @Pointer CLMem.Ptr mem_list, + PointerPtr args_mem_loc, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueNativeKernel); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + user_func, + args, + MemorySegment.ofAddress(cb_args), + num_mem_objects, + (MemorySegment) (mem_list != null ? mem_list.segment() : MemorySegment.NULL), + (MemorySegment) (args_mem_loc != null ? args_mem_loc.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int enqueueNativeKernel( + Arena arena, + CLCommandQueue command_queue, + Iuser_func_0 user_func, + @Pointer(comment="void*") MemorySegment args, + long cb_args, + @NativeType("cl_uint") @Unsigned int num_mem_objects, + @Pointer CLMem.Ptr mem_list, + PointerPtr args_mem_loc, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + return enqueueNativeKernel( + command_queue, + Iuser_func_0.ofNative(arena, user_func), + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event + ); + } + + public @NativeType("cl_int") int enqueueNativeKernel( + CLCommandQueue command_queue, + Iuser_func_0 user_func, + @Pointer(comment="void*") MemorySegment args, + long cb_args, + @NativeType("cl_uint") @Unsigned int num_mem_objects, + @Pointer CLMem.Ptr mem_list, + PointerPtr args_mem_loc, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + return enqueueNativeKernel( + Arena.global(), + command_queue, + user_func, + args, + cb_args, + num_mem_objects, + mem_list, + args_mem_loc, + num_events_in_wait_list, + event_wait_list, + event + ); + } + + /// @see clEnqueueMarkerWithWaitList + public @NativeType("cl_int") int enqueueMarkerWithWaitList( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMarkerWithWaitList); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueBarrierWithWaitList + public @NativeType("cl_int") int enqueueBarrierWithWaitList( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueBarrierWithWaitList); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMFree + public @NativeType("cl_int") int enqueueSVMFree( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_svm_pointers, + @Pointer(comment="void*") MemorySegment svm_pointers, + @Pointer(comment="pfn_free_func_1") MemorySegment pfn_free_func, + @Pointer(comment="void*") MemorySegment user_data, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMFree); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_svm_pointers, + svm_pointers, + pfn_free_func, + user_data, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + public @NativeType("cl_int") int enqueueSVMFree( + Arena arena, + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_svm_pointers, + @Pointer(comment="void*") MemorySegment svm_pointers, + Ipfn_free_func_1 pfn_free_func, + @Pointer(comment="void*") MemorySegment user_data, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + return enqueueSVMFree( + command_queue, + num_svm_pointers, + svm_pointers, + Ipfn_free_func_1.ofNative(arena, pfn_free_func), + user_data, + num_events_in_wait_list, + event_wait_list, + event + ); + } + + public @NativeType("cl_int") int enqueueSVMFree( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_svm_pointers, + @Pointer(comment="void*") MemorySegment svm_pointers, + Ipfn_free_func_1 pfn_free_func, + @Pointer(comment="void*") MemorySegment user_data, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + return enqueueSVMFree( + Arena.global(), + command_queue, + num_svm_pointers, + svm_pointers, + pfn_free_func, + user_data, + num_events_in_wait_list, + event_wait_list, + event + ); + } + + /// @see clEnqueueSVMMemcpy + public @NativeType("cl_int") int enqueueSVMMemcpy( + CLCommandQueue command_queue, + @NativeType("cl_bool") @Unsigned int blocking_copy, + @Pointer(comment="void*") MemorySegment dst_ptr, + @Pointer(comment="void*") MemorySegment src_ptr, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMMemcpy); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + blocking_copy, + dst_ptr, + src_ptr, + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMMemFill + public @NativeType("cl_int") int enqueueSVMMemFill( + CLCommandQueue command_queue, + @Pointer(comment="void*") MemorySegment svm_ptr, + @Pointer(comment="void*") MemorySegment pattern, + long pattern_size, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMMemFill); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + svm_ptr, + pattern, + MemorySegment.ofAddress(pattern_size), + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMMap + public @NativeType("cl_int") int enqueueSVMMap( + CLCommandQueue command_queue, + @NativeType("cl_bool") @Unsigned int blocking_map, + @NativeType("cl_map_flags") @Unsigned long flags, + @Pointer(comment="void*") MemorySegment svm_ptr, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMMap); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + blocking_map, + flags, + svm_ptr, + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMUnmap + public @NativeType("cl_int") int enqueueSVMUnmap( + CLCommandQueue command_queue, + @Pointer(comment="void*") MemorySegment svm_ptr, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMUnmap); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + svm_ptr, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueSVMMigrateMem + public @NativeType("cl_int") int enqueueSVMMigrateMem( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_svm_pointers, + PointerPtr svm_pointers, + PointerPtr sizes, + @NativeType("cl_mem_migration_flags") @Unsigned long flags, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueSVMMigrateMem); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_svm_pointers, + (MemorySegment) (svm_pointers != null ? svm_pointers.segment() : MemorySegment.NULL), + (MemorySegment) (sizes != null ? sizes.segment() : MemorySegment.NULL), + flags, + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetExtensionFunctionAddressForPlatform + public @Pointer(comment="void*") MemorySegment getExtensionFunctionAddressForPlatform( + CLPlatformId platform, + BytePtr func_name + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetExtensionFunctionAddressForPlatform); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (platform != null ? platform.segment() : MemorySegment.NULL), + (MemorySegment) (func_name != null ? func_name.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetCommandQueueProperty + public @NativeType("cl_int") int setCommandQueueProperty( + CLCommandQueue command_queue, + @NativeType("cl_command_queue_properties") @Unsigned long properties, + @NativeType("cl_bool") @Unsigned int enable, + @Pointer(comment="cl_command_queue_properties") @Unsigned LongPtr old_properties + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetCommandQueueProperty); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + properties, + enable, + (MemorySegment) (old_properties != null ? old_properties.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateImage2D + public CLMem createImage2D( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @Pointer CLImageFormat image_format, + long imageWidth, + long imageHeight, + long imageRowPitch, + @Pointer(comment="void*") MemorySegment host_ptr, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateImage2D); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (image_format != null ? image_format.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(imageWidth), + MemorySegment.ofAddress(imageHeight), + MemorySegment.ofAddress(imageRowPitch), + host_ptr, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateImage3D + public CLMem createImage3D( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @Pointer CLImageFormat image_format, + long imageWidth, + long imageHeight, + long imageDepth, + long imageRowPitch, + long imageSlicePitch, + @Pointer(comment="void*") MemorySegment host_ptr, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateImage3D); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (image_format != null ? image_format.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(imageWidth), + MemorySegment.ofAddress(imageHeight), + MemorySegment.ofAddress(imageDepth), + MemorySegment.ofAddress(imageRowPitch), + MemorySegment.ofAddress(imageSlicePitch), + host_ptr, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueMarker + public @NativeType("cl_int") int enqueueMarker( + CLCommandQueue command_queue, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueMarker); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueWaitForEvents + public @NativeType("cl_int") int enqueueWaitForEvents( + CLCommandQueue command_queue, + @NativeType("cl_uint") @Unsigned int num_events, + @Pointer CLEvent.Ptr event_list + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueWaitForEvents); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + num_events, + (MemorySegment) (event_list != null ? event_list.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueBarrier + public @NativeType("cl_int") int enqueueBarrier( + CLCommandQueue command_queue + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueBarrier); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clUnloadCompiler + public @NativeType("cl_int") int unloadCompiler() { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clUnloadCompiler); + try { + return (int) hFunction.invokeExact( + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetExtensionFunctionAddress + public @Pointer(comment="void*") MemorySegment getExtensionFunctionAddress( + BytePtr func_name + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetExtensionFunctionAddress); + try { + return (MemorySegment) hFunction.invokeExact( + (MemorySegment) (func_name != null ? func_name.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateCommandQueue + public CLCommandQueue createCommandQueue( + CLContext context, + CLDeviceId device, + @NativeType("cl_command_queue_properties") @Unsigned long properties, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateCommandQueue); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (device != null ? device.segment() : MemorySegment.NULL), + properties, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLCommandQueue(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCreateSampler + public CLSampler createSampler( + CLContext context, + @NativeType("cl_bool") @Unsigned int normalized_coords, + @NativeType("cl_addressing_mode") @Unsigned int addressing_mode, + @NativeType("cl_filter_mode") @Unsigned int filter_mode, + @Pointer(comment="cl_int") IntPtr errcode_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCreateSampler); + try { + MemorySegment s = (MemorySegment) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + normalized_coords, + addressing_mode, + filter_mode, + (MemorySegment) (errcode_ret != null ? errcode_ret.segment() : MemorySegment.NULL) + ); + return s.equals(MemorySegment.NULL) ? null : new CLSampler(s); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueTask + public @NativeType("cl_int") int enqueueTask( + CLCommandQueue command_queue, + CLKernel kernel, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueTask); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (kernel != null ? kernel.segment() : MemorySegment.NULL), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetLayerInfo + public @NativeType("cl_int") int getLayerInfo( + @NativeType("cl_layer_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetLayerInfo); + try { + return (int) hFunction.invokeExact( + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clInitLayer + public @NativeType("cl_int") int initLayer( + @NativeType("cl_uint") @Unsigned int num_entries, + CLIcdDispatch target_dispatch, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_entries_ret, + @Pointer CLIcdDispatch.Ptr layer_dispatch_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clInitLayer); + try { + return (int) hFunction.invokeExact( + num_entries, + (MemorySegment) (target_dispatch != null ? target_dispatch.segment() : MemorySegment.NULL), + (MemorySegment) (num_entries_ret != null ? num_entries_ret.segment() : MemorySegment.NULL), + (MemorySegment) (layer_dispatch_ret != null ? layer_dispatch_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetICDLoaderInfoOCLICD + public @NativeType("cl_int") int getICDLoaderInfoOCLICD( + @NativeType("cl_icdl_info") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetICDLoaderInfoOCLICD); + try { + return (int) hFunction.invokeExact( + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSupportedGLTextureFormatsINTEL + public @NativeType("cl_int") int getSupportedGLTextureFormatsINTEL( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_mem_object_type") @Unsigned int imageType, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer(comment="cl_GLenum") @Unsigned IntPtr gl_formats, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_texture_formats + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSupportedGLTextureFormatsINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + imageType, + num_entries, + (MemorySegment) (gl_formats != null ? gl_formats.segment() : MemorySegment.NULL), + (MemorySegment) (num_texture_formats != null ? num_texture_formats.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSupportedDX9MediaSurfaceFormatsINTEL + public @NativeType("cl_int") int getSupportedDX9MediaSurfaceFormatsINTEL( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_mem_object_type") @Unsigned int imageType, + @NativeType("cl_uint") @Unsigned int plane, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer(comment="D3DFORMAT") @Unsigned IntPtr dx9_formats, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_surface_formats + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSupportedDX9MediaSurfaceFormatsINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + imageType, + plane, + num_entries, + (MemorySegment) (dx9_formats != null ? dx9_formats.segment() : MemorySegment.NULL), + (MemorySegment) (num_surface_formats != null ? num_surface_formats.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSupportedD3D10TextureFormatsINTEL + public @NativeType("cl_int") int getSupportedD3D10TextureFormatsINTEL( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_mem_object_type") @Unsigned int imageType, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer(comment="DXGI_FORMAT") @Unsigned IntPtr d3d10_formats, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_texture_formats + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSupportedD3D10TextureFormatsINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + imageType, + num_entries, + (MemorySegment) (d3d10_formats != null ? d3d10_formats.segment() : MemorySegment.NULL), + (MemorySegment) (num_texture_formats != null ? num_texture_formats.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSupportedD3D11TextureFormatsINTEL + public @NativeType("cl_int") int getSupportedD3D11TextureFormatsINTEL( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_mem_object_type") @Unsigned int imageType, + @NativeType("cl_uint") @Unsigned int plane, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer(comment="DXGI_FORMAT") @Unsigned IntPtr d3d11_formats, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_texture_formats + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSupportedD3D11TextureFormatsINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + imageType, + plane, + num_entries, + (MemorySegment) (d3d11_formats != null ? d3d11_formats.segment() : MemorySegment.NULL), + (MemorySegment) (num_texture_formats != null ? num_texture_formats.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetSupportedVA_APIMediaSurfaceFormatsINTEL + public @NativeType("cl_int") int getSupportedVA_APIMediaSurfaceFormatsINTEL( + CLContext context, + @NativeType("cl_mem_flags") @Unsigned long flags, + @NativeType("cl_mem_object_type") @Unsigned int imageType, + @NativeType("cl_uint") @Unsigned int plane, + @NativeType("cl_uint") @Unsigned int num_entries, + @Pointer VAImageFormatCLREF va_api_formats, + @Pointer(comment="cl_uint") @Unsigned IntPtr num_surface_formats + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetSupportedVA_APIMediaSurfaceFormatsINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + flags, + imageType, + plane, + num_entries, + (MemorySegment) (va_api_formats != null ? va_api_formats.segment() : MemorySegment.NULL), + (MemorySegment) (num_surface_formats != null ? num_surface_formats.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueReadHostPipeINTEL + public @NativeType("cl_int") int enqueueReadHostPipeINTEL( + CLCommandQueue command_queue, + CLProgram program, + BytePtr pipe_symbol, + @NativeType("cl_bool") @Unsigned int blocking_read, + @Pointer(comment="void*") MemorySegment ptr, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueReadHostPipeINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + (MemorySegment) (pipe_symbol != null ? pipe_symbol.segment() : MemorySegment.NULL), + blocking_read, + ptr, + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clEnqueueWriteHostPipeINTEL + public @NativeType("cl_int") int enqueueWriteHostPipeINTEL( + CLCommandQueue command_queue, + CLProgram program, + BytePtr pipe_symbol, + @NativeType("cl_bool") @Unsigned int blocking_write, + @Pointer(comment="void*") MemorySegment ptr, + long size, + @NativeType("cl_uint") @Unsigned int num_events_in_wait_list, + @Pointer CLEvent.Ptr event_wait_list, + @Pointer CLEvent.Ptr event + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clEnqueueWriteHostPipeINTEL); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (command_queue != null ? command_queue.segment() : MemorySegment.NULL), + (MemorySegment) (program != null ? program.segment() : MemorySegment.NULL), + (MemorySegment) (pipe_symbol != null ? pipe_symbol.segment() : MemorySegment.NULL), + blocking_write, + ptr, + MemorySegment.ofAddress(size), + num_events_in_wait_list, + (MemorySegment) (event_wait_list != null ? event_wait_list.segment() : MemorySegment.NULL), + (MemorySegment) (event != null ? event.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clGetImageRequirementsInfoEXT + public @NativeType("cl_int") int getImageRequirementsInfoEXT( + CLContext context, + @Pointer(comment="cl_mem_properties") @Unsigned LongPtr properties, + @NativeType("cl_mem_flags") @Unsigned long flags, + @Pointer CLImageFormat image_format, + @Pointer CLImageDesc image_desc, + @NativeType("cl_image_requirements_info_ext") @Unsigned int paramName, + long paramValueSize, + @Pointer(comment="void*") MemorySegment paramValue, + PointerPtr param_value_size_ret + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clGetImageRequirementsInfoEXT); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + (MemorySegment) (properties != null ? properties.segment() : MemorySegment.NULL), + flags, + (MemorySegment) (image_format != null ? image_format.segment() : MemorySegment.NULL), + (MemorySegment) (image_desc != null ? image_desc.segment() : MemorySegment.NULL), + paramName, + MemorySegment.ofAddress(paramValueSize), + paramValue, + (MemorySegment) (param_value_size_ret != null ? param_value_size_ret.segment() : MemorySegment.NULL) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clCancelCommandsIMG + public @NativeType("cl_int") int cancelCommandsIMG( + @Pointer CLEvent.Ptr event_list, + long num_events_in_list + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clCancelCommandsIMG); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (event_list != null ? event_list.segment() : MemorySegment.NULL), + MemorySegment.ofAddress(num_events_in_list) + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /// @see clSetPerfHintQCOM + public @NativeType("cl_int") int setPerfHintQCOM( + CLContext context, + @NativeType("cl_perf_hint_qcom") @Unsigned int perf_hint + ) { + MethodHandle hFunction = Objects.requireNonNull(HANDLE$clSetPerfHintQCOM); + try { + return (int) hFunction.invokeExact( + (MemorySegment) (context != null ? context.segment() : MemorySegment.NULL), + perf_hint + ); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + // endregion + + // region segments and handles + public final MemorySegment SEGMENT$clGetDeviceIDsFromD3D10KHR; + public final MemorySegment SEGMENT$clCreateFromD3D10BufferKHR; + public final MemorySegment SEGMENT$clCreateFromD3D10Texture2DKHR; + public final MemorySegment SEGMENT$clCreateFromD3D10Texture3DKHR; + public final MemorySegment SEGMENT$clEnqueueAcquireD3D10ObjectsKHR; + public final MemorySegment SEGMENT$clEnqueueReleaseD3D10ObjectsKHR; + public final MemorySegment SEGMENT$clGetDeviceIDsFromD3D11KHR; + public final MemorySegment SEGMENT$clCreateFromD3D11BufferKHR; + public final MemorySegment SEGMENT$clCreateFromD3D11Texture2DKHR; + public final MemorySegment SEGMENT$clCreateFromD3D11Texture3DKHR; + public final MemorySegment SEGMENT$clEnqueueAcquireD3D11ObjectsKHR; + public final MemorySegment SEGMENT$clEnqueueReleaseD3D11ObjectsKHR; + public final MemorySegment SEGMENT$clGetDeviceIDsFromDX9MediaAdapterKHR; + public final MemorySegment SEGMENT$clCreateFromDX9MediaSurfaceKHR; + public final MemorySegment SEGMENT$clEnqueueAcquireDX9MediaSurfacesKHR; + public final MemorySegment SEGMENT$clEnqueueReleaseDX9MediaSurfacesKHR; + public final MemorySegment SEGMENT$clGetDeviceIDsFromDX9INTEL; + public final MemorySegment SEGMENT$clCreateFromDX9MediaSurfaceINTEL; + public final MemorySegment SEGMENT$clEnqueueAcquireDX9ObjectsINTEL; + public final MemorySegment SEGMENT$clEnqueueReleaseDX9ObjectsINTEL; + public final MemorySegment SEGMENT$clCreateEventFromEGLSyncKHR; + public final MemorySegment SEGMENT$clCreateFromEGLImageKHR; + public final MemorySegment SEGMENT$clEnqueueAcquireEGLObjectsKHR; + public final MemorySegment SEGMENT$clEnqueueReleaseEGLObjectsKHR; + public final MemorySegment SEGMENT$clLogMessagesToSystemLogAPPLE; + public final MemorySegment SEGMENT$clLogMessagesToStdoutAPPLE; + public final MemorySegment SEGMENT$clLogMessagesToStderrAPPLE; + public final MemorySegment SEGMENT$clIcdGetPlatformIDsKHR; + public final MemorySegment SEGMENT$clIcdGetFunctionAddressForPlatformKHR; + public final MemorySegment SEGMENT$clIcdSetPlatformDispatchDataKHR; + public final MemorySegment SEGMENT$clCreateProgramWithILKHR; + public final MemorySegment SEGMENT$clTerminateContextKHR; + public final MemorySegment SEGMENT$clCreateCommandQueueWithPropertiesKHR; + public final MemorySegment SEGMENT$clReleaseDeviceEXT; + public final MemorySegment SEGMENT$clRetainDeviceEXT; + public final MemorySegment SEGMENT$clCreateSubDevicesEXT; + public final MemorySegment SEGMENT$clEnqueueMigrateMemObjectEXT; + public final MemorySegment SEGMENT$clGetDeviceImageInfoQCOM; + public final MemorySegment SEGMENT$clEnqueueAcquireGrallocObjectsIMG; + public final MemorySegment SEGMENT$clEnqueueGenerateMipmapIMG; + public final MemorySegment SEGMENT$clEnqueueReleaseGrallocObjectsIMG; + public final MemorySegment SEGMENT$clGetKernelSubGroupInfoKHR; + public final MemorySegment SEGMENT$clGetKernelSuggestedLocalWorkSizeKHR; + public final MemorySegment SEGMENT$clCreateSemaphoreWithPropertiesKHR; + public final MemorySegment SEGMENT$clEnqueueWaitSemaphoresKHR; + public final MemorySegment SEGMENT$clEnqueueSignalSemaphoresKHR; + public final MemorySegment SEGMENT$clGetSemaphoreInfoKHR; + public final MemorySegment SEGMENT$clReleaseSemaphoreKHR; + public final MemorySegment SEGMENT$clRetainSemaphoreKHR; + public final MemorySegment SEGMENT$clGetSemaphoreHandleForTypeKHR; + public final MemorySegment SEGMENT$clReImportSemaphoreSyncFdKHR; + public final MemorySegment SEGMENT$clEnqueueAcquireExternalMemObjectsKHR; + public final MemorySegment SEGMENT$clEnqueueReleaseExternalMemObjectsKHR; + public final MemorySegment SEGMENT$clImportMemoryARM; + public final MemorySegment SEGMENT$clSVMAllocARM; + public final MemorySegment SEGMENT$clSVMFreeARM; + public final MemorySegment SEGMENT$clEnqueueSVMFreeARM; + public final MemorySegment SEGMENT$clEnqueueSVMMemcpyARM; + public final MemorySegment SEGMENT$clEnqueueSVMMemFillARM; + public final MemorySegment SEGMENT$clEnqueueSVMMapARM; + public final MemorySegment SEGMENT$clEnqueueSVMUnmapARM; + public final MemorySegment SEGMENT$clSetKernelArgSVMPointerARM; + public final MemorySegment SEGMENT$clSetKernelExecInfoARM; + public final MemorySegment SEGMENT$clCreateAcceleratorINTEL; + public final MemorySegment SEGMENT$clGetAcceleratorInfoINTEL; + public final MemorySegment SEGMENT$clRetainAcceleratorINTEL; + public final MemorySegment SEGMENT$clReleaseAcceleratorINTEL; + public final MemorySegment SEGMENT$clCreateEventFromGLsyncKHR; + public final MemorySegment SEGMENT$clGetGLContextInfoKHR; + public final MemorySegment SEGMENT$clCreateFromGLBuffer; + public final MemorySegment SEGMENT$clCreateFromGLTexture; + public final MemorySegment SEGMENT$clCreateFromGLRenderbuffer; + public final MemorySegment SEGMENT$clGetGLObjectInfo; + public final MemorySegment SEGMENT$clGetGLTextureInfo; + public final MemorySegment SEGMENT$clEnqueueAcquireGLObjects; + public final MemorySegment SEGMENT$clEnqueueReleaseGLObjects; + public final MemorySegment SEGMENT$clCreateFromGLTexture2D; + public final MemorySegment SEGMENT$clCreateFromGLTexture3D; + public final MemorySegment SEGMENT$clGetDeviceIDsFromVA_APIMediaAdapterINTEL; + public final MemorySegment SEGMENT$clCreateFromVA_APIMediaSurfaceINTEL; + public final MemorySegment SEGMENT$clEnqueueAcquireVA_APIMediaSurfacesINTEL; + public final MemorySegment SEGMENT$clEnqueueReleaseVA_APIMediaSurfacesINTEL; + public final MemorySegment SEGMENT$clHostMemAllocINTEL; + public final MemorySegment SEGMENT$clDeviceMemAllocINTEL; + public final MemorySegment SEGMENT$clSharedMemAllocINTEL; + public final MemorySegment SEGMENT$clMemFreeINTEL; + public final MemorySegment SEGMENT$clMemBlockingFreeINTEL; + public final MemorySegment SEGMENT$clGetMemAllocInfoINTEL; + public final MemorySegment SEGMENT$clSetKernelArgMemPointerINTEL; + public final MemorySegment SEGMENT$clEnqueueMemsetINTEL; + public final MemorySegment SEGMENT$clEnqueueMemFillINTEL; + public final MemorySegment SEGMENT$clEnqueueMemcpyINTEL; + public final MemorySegment SEGMENT$clEnqueueMigrateMemINTEL; + public final MemorySegment SEGMENT$clEnqueueMemAdviseINTEL; + public final MemorySegment SEGMENT$clCreateBufferWithPropertiesINTEL; + public final MemorySegment SEGMENT$clCreateCommandBufferKHR; + public final MemorySegment SEGMENT$clFinalizeCommandBufferKHR; + public final MemorySegment SEGMENT$clRetainCommandBufferKHR; + public final MemorySegment SEGMENT$clReleaseCommandBufferKHR; + public final MemorySegment SEGMENT$clEnqueueCommandBufferKHR; + public final MemorySegment SEGMENT$clCommandBarrierWithWaitListKHR; + public final MemorySegment SEGMENT$clCommandCopyBufferKHR; + public final MemorySegment SEGMENT$clCommandCopyBufferRectKHR; + public final MemorySegment SEGMENT$clCommandCopyBufferToImageKHR; + public final MemorySegment SEGMENT$clCommandCopyImageKHR; + public final MemorySegment SEGMENT$clCommandCopyImageToBufferKHR; + public final MemorySegment SEGMENT$clCommandFillBufferKHR; + public final MemorySegment SEGMENT$clCommandFillImageKHR; + public final MemorySegment SEGMENT$clCommandNDRangeKernelKHR; + public final MemorySegment SEGMENT$clCommandSVMMemcpyKHR; + public final MemorySegment SEGMENT$clCommandSVMMemFillKHR; + public final MemorySegment SEGMENT$clGetCommandBufferInfoKHR; + public final MemorySegment SEGMENT$clUpdateMutableCommandsKHR; + public final MemorySegment SEGMENT$clGetMutableCommandInfoKHR; + public final MemorySegment SEGMENT$clRemapCommandBufferKHR; + public final MemorySegment SEGMENT$clSetContentSizeBufferPoCL; + public final MemorySegment SEGMENT$clGetPlatformIDs; + public final MemorySegment SEGMENT$clGetPlatformInfo; + public final MemorySegment SEGMENT$clGetDeviceIDs; + public final MemorySegment SEGMENT$clGetDeviceInfo; + public final MemorySegment SEGMENT$clCreateSubDevices; + public final MemorySegment SEGMENT$clRetainDevice; + public final MemorySegment SEGMENT$clReleaseDevice; + public final MemorySegment SEGMENT$clSetDefaultDeviceCommandQueue; + public final MemorySegment SEGMENT$clGetDeviceAndHostTimer; + public final MemorySegment SEGMENT$clGetHostTimer; + public final MemorySegment SEGMENT$clCreateContext; + public final MemorySegment SEGMENT$clCreateContextFromType; + public final MemorySegment SEGMENT$clRetainContext; + public final MemorySegment SEGMENT$clReleaseContext; + public final MemorySegment SEGMENT$clGetContextInfo; + public final MemorySegment SEGMENT$clSetContextDestructorCallback; + public final MemorySegment SEGMENT$clCreateCommandQueueWithProperties; + public final MemorySegment SEGMENT$clRetainCommandQueue; + public final MemorySegment SEGMENT$clReleaseCommandQueue; + public final MemorySegment SEGMENT$clGetCommandQueueInfo; + public final MemorySegment SEGMENT$clCreateBuffer; + public final MemorySegment SEGMENT$clCreateBufferWithProperties; + public final MemorySegment SEGMENT$clCreateSubBuffer; + public final MemorySegment SEGMENT$clCreateImage; + public final MemorySegment SEGMENT$clCreateImageWithProperties; + public final MemorySegment SEGMENT$clCreatePipe; + public final MemorySegment SEGMENT$clRetainMemObject; + public final MemorySegment SEGMENT$clReleaseMemObject; + public final MemorySegment SEGMENT$clGetSupportedImageFormats; + public final MemorySegment SEGMENT$clGetMemObjectInfo; + public final MemorySegment SEGMENT$clGetImageInfo; + public final MemorySegment SEGMENT$clGetPipeInfo; + public final MemorySegment SEGMENT$clSetMemObjectDestructorCallback; + public final MemorySegment SEGMENT$clSetMemObjectDestructorAPPLE; + public final MemorySegment SEGMENT$clSVMAlloc; + public final MemorySegment SEGMENT$clSVMFree; + public final MemorySegment SEGMENT$clCreateSamplerWithProperties; + public final MemorySegment SEGMENT$clRetainSampler; + public final MemorySegment SEGMENT$clReleaseSampler; + public final MemorySegment SEGMENT$clGetSamplerInfo; + public final MemorySegment SEGMENT$clCreateProgramWithSource; + public final MemorySegment SEGMENT$clCreateProgramWithBinary; + public final MemorySegment SEGMENT$clCreateProgramWithBuiltInKernels; + public final MemorySegment SEGMENT$clCreateProgramWithIL; + public final MemorySegment SEGMENT$clRetainProgram; + public final MemorySegment SEGMENT$clReleaseProgram; + public final MemorySegment SEGMENT$clBuildProgram; + public final MemorySegment SEGMENT$clCompileProgram; + public final MemorySegment SEGMENT$clLinkProgram; + public final MemorySegment SEGMENT$clSetProgramReleaseCallback; + public final MemorySegment SEGMENT$clSetProgramSpecializationConstant; + public final MemorySegment SEGMENT$clUnloadPlatformCompiler; + public final MemorySegment SEGMENT$clGetProgramInfo; + public final MemorySegment SEGMENT$clGetProgramBuildInfo; + public final MemorySegment SEGMENT$clCreateKernel; + public final MemorySegment SEGMENT$clCreateKernelsInProgram; + public final MemorySegment SEGMENT$clCloneKernel; + public final MemorySegment SEGMENT$clRetainKernel; + public final MemorySegment SEGMENT$clReleaseKernel; + public final MemorySegment SEGMENT$clSetKernelArg; + public final MemorySegment SEGMENT$clSetKernelArgSVMPointer; + public final MemorySegment SEGMENT$clSetKernelArgDevicePointerEXT; + public final MemorySegment SEGMENT$clSetKernelExecInfo; + public final MemorySegment SEGMENT$clGetKernelInfo; + public final MemorySegment SEGMENT$clGetKernelArgInfo; + public final MemorySegment SEGMENT$clGetKernelWorkGroupInfo; + public final MemorySegment SEGMENT$clGetKernelSubGroupInfo; + public final MemorySegment SEGMENT$clWaitForEvents; + public final MemorySegment SEGMENT$clGetEventInfo; + public final MemorySegment SEGMENT$clCreateUserEvent; + public final MemorySegment SEGMENT$clRetainEvent; + public final MemorySegment SEGMENT$clReleaseEvent; + public final MemorySegment SEGMENT$clSetUserEventStatus; + public final MemorySegment SEGMENT$clSetEventCallback; + public final MemorySegment SEGMENT$clGetEventProfilingInfo; + public final MemorySegment SEGMENT$clFlush; + public final MemorySegment SEGMENT$clFinish; + public final MemorySegment SEGMENT$clEnqueueReadBuffer; + public final MemorySegment SEGMENT$clEnqueueReadBufferRect; + public final MemorySegment SEGMENT$clEnqueueWriteBuffer; + public final MemorySegment SEGMENT$clEnqueueWriteBufferRect; + public final MemorySegment SEGMENT$clEnqueueFillBuffer; + public final MemorySegment SEGMENT$clEnqueueCopyBuffer; + public final MemorySegment SEGMENT$clEnqueueCopyBufferRect; + public final MemorySegment SEGMENT$clEnqueueReadImage; + public final MemorySegment SEGMENT$clEnqueueWriteImage; + public final MemorySegment SEGMENT$clEnqueueFillImage; + public final MemorySegment SEGMENT$clEnqueueCopyImage; + public final MemorySegment SEGMENT$clEnqueueCopyImageToBuffer; + public final MemorySegment SEGMENT$clEnqueueCopyBufferToImage; + public final MemorySegment SEGMENT$clEnqueueMapBuffer; + public final MemorySegment SEGMENT$clEnqueueMapImage; + public final MemorySegment SEGMENT$clEnqueueUnmapMemObject; + public final MemorySegment SEGMENT$clEnqueueMigrateMemObjects; + public final MemorySegment SEGMENT$clEnqueueNDRangeKernel; + public final MemorySegment SEGMENT$clEnqueueNativeKernel; + public final MemorySegment SEGMENT$clEnqueueMarkerWithWaitList; + public final MemorySegment SEGMENT$clEnqueueBarrierWithWaitList; + public final MemorySegment SEGMENT$clEnqueueSVMFree; + public final MemorySegment SEGMENT$clEnqueueSVMMemcpy; + public final MemorySegment SEGMENT$clEnqueueSVMMemFill; + public final MemorySegment SEGMENT$clEnqueueSVMMap; + public final MemorySegment SEGMENT$clEnqueueSVMUnmap; + public final MemorySegment SEGMENT$clEnqueueSVMMigrateMem; + public final MemorySegment SEGMENT$clGetExtensionFunctionAddressForPlatform; + public final MemorySegment SEGMENT$clSetCommandQueueProperty; + public final MemorySegment SEGMENT$clCreateImage2D; + public final MemorySegment SEGMENT$clCreateImage3D; + public final MemorySegment SEGMENT$clEnqueueMarker; + public final MemorySegment SEGMENT$clEnqueueWaitForEvents; + public final MemorySegment SEGMENT$clEnqueueBarrier; + public final MemorySegment SEGMENT$clUnloadCompiler; + public final MemorySegment SEGMENT$clGetExtensionFunctionAddress; + public final MemorySegment SEGMENT$clCreateCommandQueue; + public final MemorySegment SEGMENT$clCreateSampler; + public final MemorySegment SEGMENT$clEnqueueTask; + public final MemorySegment SEGMENT$clGetLayerInfo; + public final MemorySegment SEGMENT$clInitLayer; + public final MemorySegment SEGMENT$clGetICDLoaderInfoOCLICD; + public final MemorySegment SEGMENT$clGetSupportedGLTextureFormatsINTEL; + public final MemorySegment SEGMENT$clGetSupportedDX9MediaSurfaceFormatsINTEL; + public final MemorySegment SEGMENT$clGetSupportedD3D10TextureFormatsINTEL; + public final MemorySegment SEGMENT$clGetSupportedD3D11TextureFormatsINTEL; + public final MemorySegment SEGMENT$clGetSupportedVA_APIMediaSurfaceFormatsINTEL; + public final MemorySegment SEGMENT$clEnqueueReadHostPipeINTEL; + public final MemorySegment SEGMENT$clEnqueueWriteHostPipeINTEL; + public final MemorySegment SEGMENT$clGetImageRequirementsInfoEXT; + public final MemorySegment SEGMENT$clCancelCommandsIMG; + public final MemorySegment SEGMENT$clSetPerfHintQCOM; + public final MethodHandle HANDLE$clGetDeviceIDsFromD3D10KHR; + public final MethodHandle HANDLE$clCreateFromD3D10BufferKHR; + public final MethodHandle HANDLE$clCreateFromD3D10Texture2DKHR; + public final MethodHandle HANDLE$clCreateFromD3D10Texture3DKHR; + public final MethodHandle HANDLE$clEnqueueAcquireD3D10ObjectsKHR; + public final MethodHandle HANDLE$clEnqueueReleaseD3D10ObjectsKHR; + public final MethodHandle HANDLE$clGetDeviceIDsFromD3D11KHR; + public final MethodHandle HANDLE$clCreateFromD3D11BufferKHR; + public final MethodHandle HANDLE$clCreateFromD3D11Texture2DKHR; + public final MethodHandle HANDLE$clCreateFromD3D11Texture3DKHR; + public final MethodHandle HANDLE$clEnqueueAcquireD3D11ObjectsKHR; + public final MethodHandle HANDLE$clEnqueueReleaseD3D11ObjectsKHR; + public final MethodHandle HANDLE$clGetDeviceIDsFromDX9MediaAdapterKHR; + public final MethodHandle HANDLE$clCreateFromDX9MediaSurfaceKHR; + public final MethodHandle HANDLE$clEnqueueAcquireDX9MediaSurfacesKHR; + public final MethodHandle HANDLE$clEnqueueReleaseDX9MediaSurfacesKHR; + public final MethodHandle HANDLE$clGetDeviceIDsFromDX9INTEL; + public final MethodHandle HANDLE$clCreateFromDX9MediaSurfaceINTEL; + public final MethodHandle HANDLE$clEnqueueAcquireDX9ObjectsINTEL; + public final MethodHandle HANDLE$clEnqueueReleaseDX9ObjectsINTEL; + public final MethodHandle HANDLE$clCreateEventFromEGLSyncKHR; + public final MethodHandle HANDLE$clCreateFromEGLImageKHR; + public final MethodHandle HANDLE$clEnqueueAcquireEGLObjectsKHR; + public final MethodHandle HANDLE$clEnqueueReleaseEGLObjectsKHR; + public final MethodHandle HANDLE$clLogMessagesToSystemLogAPPLE; + public final MethodHandle HANDLE$clLogMessagesToStdoutAPPLE; + public final MethodHandle HANDLE$clLogMessagesToStderrAPPLE; + public final MethodHandle HANDLE$clIcdGetPlatformIDsKHR; + public final MethodHandle HANDLE$clIcdGetFunctionAddressForPlatformKHR; + public final MethodHandle HANDLE$clIcdSetPlatformDispatchDataKHR; + public final MethodHandle HANDLE$clCreateProgramWithILKHR; + public final MethodHandle HANDLE$clTerminateContextKHR; + public final MethodHandle HANDLE$clCreateCommandQueueWithPropertiesKHR; + public final MethodHandle HANDLE$clReleaseDeviceEXT; + public final MethodHandle HANDLE$clRetainDeviceEXT; + public final MethodHandle HANDLE$clCreateSubDevicesEXT; + public final MethodHandle HANDLE$clEnqueueMigrateMemObjectEXT; + public final MethodHandle HANDLE$clGetDeviceImageInfoQCOM; + public final MethodHandle HANDLE$clEnqueueAcquireGrallocObjectsIMG; + public final MethodHandle HANDLE$clEnqueueGenerateMipmapIMG; + public final MethodHandle HANDLE$clEnqueueReleaseGrallocObjectsIMG; + public final MethodHandle HANDLE$clGetKernelSubGroupInfoKHR; + public final MethodHandle HANDLE$clGetKernelSuggestedLocalWorkSizeKHR; + public final MethodHandle HANDLE$clCreateSemaphoreWithPropertiesKHR; + public final MethodHandle HANDLE$clEnqueueWaitSemaphoresKHR; + public final MethodHandle HANDLE$clEnqueueSignalSemaphoresKHR; + public final MethodHandle HANDLE$clGetSemaphoreInfoKHR; + public final MethodHandle HANDLE$clReleaseSemaphoreKHR; + public final MethodHandle HANDLE$clRetainSemaphoreKHR; + public final MethodHandle HANDLE$clGetSemaphoreHandleForTypeKHR; + public final MethodHandle HANDLE$clReImportSemaphoreSyncFdKHR; + public final MethodHandle HANDLE$clEnqueueAcquireExternalMemObjectsKHR; + public final MethodHandle HANDLE$clEnqueueReleaseExternalMemObjectsKHR; + public final MethodHandle HANDLE$clImportMemoryARM; + public final MethodHandle HANDLE$clSVMAllocARM; + public final MethodHandle HANDLE$clSVMFreeARM; + public final MethodHandle HANDLE$clEnqueueSVMFreeARM; + public final MethodHandle HANDLE$clEnqueueSVMMemcpyARM; + public final MethodHandle HANDLE$clEnqueueSVMMemFillARM; + public final MethodHandle HANDLE$clEnqueueSVMMapARM; + public final MethodHandle HANDLE$clEnqueueSVMUnmapARM; + public final MethodHandle HANDLE$clSetKernelArgSVMPointerARM; + public final MethodHandle HANDLE$clSetKernelExecInfoARM; + public final MethodHandle HANDLE$clCreateAcceleratorINTEL; + public final MethodHandle HANDLE$clGetAcceleratorInfoINTEL; + public final MethodHandle HANDLE$clRetainAcceleratorINTEL; + public final MethodHandle HANDLE$clReleaseAcceleratorINTEL; + public final MethodHandle HANDLE$clCreateEventFromGLsyncKHR; + public final MethodHandle HANDLE$clGetGLContextInfoKHR; + public final MethodHandle HANDLE$clCreateFromGLBuffer; + public final MethodHandle HANDLE$clCreateFromGLTexture; + public final MethodHandle HANDLE$clCreateFromGLRenderbuffer; + public final MethodHandle HANDLE$clGetGLObjectInfo; + public final MethodHandle HANDLE$clGetGLTextureInfo; + public final MethodHandle HANDLE$clEnqueueAcquireGLObjects; + public final MethodHandle HANDLE$clEnqueueReleaseGLObjects; + public final MethodHandle HANDLE$clCreateFromGLTexture2D; + public final MethodHandle HANDLE$clCreateFromGLTexture3D; + public final MethodHandle HANDLE$clGetDeviceIDsFromVA_APIMediaAdapterINTEL; + public final MethodHandle HANDLE$clCreateFromVA_APIMediaSurfaceINTEL; + public final MethodHandle HANDLE$clEnqueueAcquireVA_APIMediaSurfacesINTEL; + public final MethodHandle HANDLE$clEnqueueReleaseVA_APIMediaSurfacesINTEL; + public final MethodHandle HANDLE$clHostMemAllocINTEL; + public final MethodHandle HANDLE$clDeviceMemAllocINTEL; + public final MethodHandle HANDLE$clSharedMemAllocINTEL; + public final MethodHandle HANDLE$clMemFreeINTEL; + public final MethodHandle HANDLE$clMemBlockingFreeINTEL; + public final MethodHandle HANDLE$clGetMemAllocInfoINTEL; + public final MethodHandle HANDLE$clSetKernelArgMemPointerINTEL; + public final MethodHandle HANDLE$clEnqueueMemsetINTEL; + public final MethodHandle HANDLE$clEnqueueMemFillINTEL; + public final MethodHandle HANDLE$clEnqueueMemcpyINTEL; + public final MethodHandle HANDLE$clEnqueueMigrateMemINTEL; + public final MethodHandle HANDLE$clEnqueueMemAdviseINTEL; + public final MethodHandle HANDLE$clCreateBufferWithPropertiesINTEL; + public final MethodHandle HANDLE$clCreateCommandBufferKHR; + public final MethodHandle HANDLE$clFinalizeCommandBufferKHR; + public final MethodHandle HANDLE$clRetainCommandBufferKHR; + public final MethodHandle HANDLE$clReleaseCommandBufferKHR; + public final MethodHandle HANDLE$clEnqueueCommandBufferKHR; + public final MethodHandle HANDLE$clCommandBarrierWithWaitListKHR; + public final MethodHandle HANDLE$clCommandCopyBufferKHR; + public final MethodHandle HANDLE$clCommandCopyBufferRectKHR; + public final MethodHandle HANDLE$clCommandCopyBufferToImageKHR; + public final MethodHandle HANDLE$clCommandCopyImageKHR; + public final MethodHandle HANDLE$clCommandCopyImageToBufferKHR; + public final MethodHandle HANDLE$clCommandFillBufferKHR; + public final MethodHandle HANDLE$clCommandFillImageKHR; + public final MethodHandle HANDLE$clCommandNDRangeKernelKHR; + public final MethodHandle HANDLE$clCommandSVMMemcpyKHR; + public final MethodHandle HANDLE$clCommandSVMMemFillKHR; + public final MethodHandle HANDLE$clGetCommandBufferInfoKHR; + public final MethodHandle HANDLE$clUpdateMutableCommandsKHR; + public final MethodHandle HANDLE$clGetMutableCommandInfoKHR; + public final MethodHandle HANDLE$clRemapCommandBufferKHR; + public final MethodHandle HANDLE$clSetContentSizeBufferPoCL; + public final MethodHandle HANDLE$clGetPlatformIDs; + public final MethodHandle HANDLE$clGetPlatformInfo; + public final MethodHandle HANDLE$clGetDeviceIDs; + public final MethodHandle HANDLE$clGetDeviceInfo; + public final MethodHandle HANDLE$clCreateSubDevices; + public final MethodHandle HANDLE$clRetainDevice; + public final MethodHandle HANDLE$clReleaseDevice; + public final MethodHandle HANDLE$clSetDefaultDeviceCommandQueue; + public final MethodHandle HANDLE$clGetDeviceAndHostTimer; + public final MethodHandle HANDLE$clGetHostTimer; + public final MethodHandle HANDLE$clCreateContext; + public final MethodHandle HANDLE$clCreateContextFromType; + public final MethodHandle HANDLE$clRetainContext; + public final MethodHandle HANDLE$clReleaseContext; + public final MethodHandle HANDLE$clGetContextInfo; + public final MethodHandle HANDLE$clSetContextDestructorCallback; + public final MethodHandle HANDLE$clCreateCommandQueueWithProperties; + public final MethodHandle HANDLE$clRetainCommandQueue; + public final MethodHandle HANDLE$clReleaseCommandQueue; + public final MethodHandle HANDLE$clGetCommandQueueInfo; + public final MethodHandle HANDLE$clCreateBuffer; + public final MethodHandle HANDLE$clCreateBufferWithProperties; + public final MethodHandle HANDLE$clCreateSubBuffer; + public final MethodHandle HANDLE$clCreateImage; + public final MethodHandle HANDLE$clCreateImageWithProperties; + public final MethodHandle HANDLE$clCreatePipe; + public final MethodHandle HANDLE$clRetainMemObject; + public final MethodHandle HANDLE$clReleaseMemObject; + public final MethodHandle HANDLE$clGetSupportedImageFormats; + public final MethodHandle HANDLE$clGetMemObjectInfo; + public final MethodHandle HANDLE$clGetImageInfo; + public final MethodHandle HANDLE$clGetPipeInfo; + public final MethodHandle HANDLE$clSetMemObjectDestructorCallback; + public final MethodHandle HANDLE$clSetMemObjectDestructorAPPLE; + public final MethodHandle HANDLE$clSVMAlloc; + public final MethodHandle HANDLE$clSVMFree; + public final MethodHandle HANDLE$clCreateSamplerWithProperties; + public final MethodHandle HANDLE$clRetainSampler; + public final MethodHandle HANDLE$clReleaseSampler; + public final MethodHandle HANDLE$clGetSamplerInfo; + public final MethodHandle HANDLE$clCreateProgramWithSource; + public final MethodHandle HANDLE$clCreateProgramWithBinary; + public final MethodHandle HANDLE$clCreateProgramWithBuiltInKernels; + public final MethodHandle HANDLE$clCreateProgramWithIL; + public final MethodHandle HANDLE$clRetainProgram; + public final MethodHandle HANDLE$clReleaseProgram; + public final MethodHandle HANDLE$clBuildProgram; + public final MethodHandle HANDLE$clCompileProgram; + public final MethodHandle HANDLE$clLinkProgram; + public final MethodHandle HANDLE$clSetProgramReleaseCallback; + public final MethodHandle HANDLE$clSetProgramSpecializationConstant; + public final MethodHandle HANDLE$clUnloadPlatformCompiler; + public final MethodHandle HANDLE$clGetProgramInfo; + public final MethodHandle HANDLE$clGetProgramBuildInfo; + public final MethodHandle HANDLE$clCreateKernel; + public final MethodHandle HANDLE$clCreateKernelsInProgram; + public final MethodHandle HANDLE$clCloneKernel; + public final MethodHandle HANDLE$clRetainKernel; + public final MethodHandle HANDLE$clReleaseKernel; + public final MethodHandle HANDLE$clSetKernelArg; + public final MethodHandle HANDLE$clSetKernelArgSVMPointer; + public final MethodHandle HANDLE$clSetKernelArgDevicePointerEXT; + public final MethodHandle HANDLE$clSetKernelExecInfo; + public final MethodHandle HANDLE$clGetKernelInfo; + public final MethodHandle HANDLE$clGetKernelArgInfo; + public final MethodHandle HANDLE$clGetKernelWorkGroupInfo; + public final MethodHandle HANDLE$clGetKernelSubGroupInfo; + public final MethodHandle HANDLE$clWaitForEvents; + public final MethodHandle HANDLE$clGetEventInfo; + public final MethodHandle HANDLE$clCreateUserEvent; + public final MethodHandle HANDLE$clRetainEvent; + public final MethodHandle HANDLE$clReleaseEvent; + public final MethodHandle HANDLE$clSetUserEventStatus; + public final MethodHandle HANDLE$clSetEventCallback; + public final MethodHandle HANDLE$clGetEventProfilingInfo; + public final MethodHandle HANDLE$clFlush; + public final MethodHandle HANDLE$clFinish; + public final MethodHandle HANDLE$clEnqueueReadBuffer; + public final MethodHandle HANDLE$clEnqueueReadBufferRect; + public final MethodHandle HANDLE$clEnqueueWriteBuffer; + public final MethodHandle HANDLE$clEnqueueWriteBufferRect; + public final MethodHandle HANDLE$clEnqueueFillBuffer; + public final MethodHandle HANDLE$clEnqueueCopyBuffer; + public final MethodHandle HANDLE$clEnqueueCopyBufferRect; + public final MethodHandle HANDLE$clEnqueueReadImage; + public final MethodHandle HANDLE$clEnqueueWriteImage; + public final MethodHandle HANDLE$clEnqueueFillImage; + public final MethodHandle HANDLE$clEnqueueCopyImage; + public final MethodHandle HANDLE$clEnqueueCopyImageToBuffer; + public final MethodHandle HANDLE$clEnqueueCopyBufferToImage; + public final MethodHandle HANDLE$clEnqueueMapBuffer; + public final MethodHandle HANDLE$clEnqueueMapImage; + public final MethodHandle HANDLE$clEnqueueUnmapMemObject; + public final MethodHandle HANDLE$clEnqueueMigrateMemObjects; + public final MethodHandle HANDLE$clEnqueueNDRangeKernel; + public final MethodHandle HANDLE$clEnqueueNativeKernel; + public final MethodHandle HANDLE$clEnqueueMarkerWithWaitList; + public final MethodHandle HANDLE$clEnqueueBarrierWithWaitList; + public final MethodHandle HANDLE$clEnqueueSVMFree; + public final MethodHandle HANDLE$clEnqueueSVMMemcpy; + public final MethodHandle HANDLE$clEnqueueSVMMemFill; + public final MethodHandle HANDLE$clEnqueueSVMMap; + public final MethodHandle HANDLE$clEnqueueSVMUnmap; + public final MethodHandle HANDLE$clEnqueueSVMMigrateMem; + public final MethodHandle HANDLE$clGetExtensionFunctionAddressForPlatform; + public final MethodHandle HANDLE$clSetCommandQueueProperty; + public final MethodHandle HANDLE$clCreateImage2D; + public final MethodHandle HANDLE$clCreateImage3D; + public final MethodHandle HANDLE$clEnqueueMarker; + public final MethodHandle HANDLE$clEnqueueWaitForEvents; + public final MethodHandle HANDLE$clEnqueueBarrier; + public final MethodHandle HANDLE$clUnloadCompiler; + public final MethodHandle HANDLE$clGetExtensionFunctionAddress; + public final MethodHandle HANDLE$clCreateCommandQueue; + public final MethodHandle HANDLE$clCreateSampler; + public final MethodHandle HANDLE$clEnqueueTask; + public final MethodHandle HANDLE$clGetLayerInfo; + public final MethodHandle HANDLE$clInitLayer; + public final MethodHandle HANDLE$clGetICDLoaderInfoOCLICD; + public final MethodHandle HANDLE$clGetSupportedGLTextureFormatsINTEL; + public final MethodHandle HANDLE$clGetSupportedDX9MediaSurfaceFormatsINTEL; + public final MethodHandle HANDLE$clGetSupportedD3D10TextureFormatsINTEL; + public final MethodHandle HANDLE$clGetSupportedD3D11TextureFormatsINTEL; + public final MethodHandle HANDLE$clGetSupportedVA_APIMediaSurfaceFormatsINTEL; + public final MethodHandle HANDLE$clEnqueueReadHostPipeINTEL; + public final MethodHandle HANDLE$clEnqueueWriteHostPipeINTEL; + public final MethodHandle HANDLE$clGetImageRequirementsInfoEXT; + public final MethodHandle HANDLE$clCancelCommandsIMG; + public final MethodHandle HANDLE$clSetPerfHintQCOM; + // endregion + + public static final class Descriptors { + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceIDsFromD3D10KHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromD3D10BufferKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromD3D10Texture2DKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromD3D10Texture3DKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireD3D10ObjectsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseD3D10ObjectsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceIDsFromD3D11KHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromD3D11BufferKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromD3D11Texture2DKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromD3D11Texture3DKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireD3D11ObjectsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseD3D11ObjectsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceIDsFromDX9MediaAdapterKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromDX9MediaSurfaceKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireDX9MediaSurfacesKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseDX9MediaSurfacesKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceIDsFromDX9INTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromDX9MediaSurfaceINTEL = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireDX9ObjectsINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseDX9ObjectsINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateEventFromEGLSyncKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromEGLImageKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireEGLObjectsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseEGLObjectsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clLogMessagesToSystemLogAPPLE = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clLogMessagesToStdoutAPPLE = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clLogMessagesToStderrAPPLE = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clIcdGetPlatformIDsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clIcdGetFunctionAddressForPlatformKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE) + ); + + public static final FunctionDescriptor DESCRIPTOR$clIcdSetPlatformDispatchDataKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateProgramWithILKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clTerminateContextKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateCommandQueueWithPropertiesKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseDeviceEXT = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainDeviceEXT = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateSubDevicesEXT = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMigrateMemObjectEXT = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceImageInfoQCOM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS.withTargetLayout(CLImageFormat.LAYOUT), + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireGrallocObjectsIMG = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueGenerateMipmapIMG = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseGrallocObjectsIMG = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetKernelSubGroupInfoKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetKernelSuggestedLocalWorkSizeKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateSemaphoreWithPropertiesKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueWaitSemaphoresKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSignalSemaphoresKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSemaphoreInfoKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseSemaphoreKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainSemaphoreKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSemaphoreHandleForTypeKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clReImportSemaphoreSyncFdKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_INT + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireExternalMemObjectsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseExternalMemObjectsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clImportMemoryARM = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSVMAllocARM = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT + ); + + public static final FunctionDescriptor DESCRIPTOR$clSVMFreeARM = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMFreeARM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMMemcpyARM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMMemFillARM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMMapARM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMUnmapARM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetKernelArgSVMPointerARM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetKernelExecInfoARM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateAcceleratorINTEL = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetAcceleratorInfoINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainAcceleratorINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseAcceleratorINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateEventFromGLsyncKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetGLContextInfoKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromGLBuffer = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromGLTexture = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromGLRenderbuffer = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetGLObjectInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetGLTextureInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireGLObjects = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseGLObjects = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromGLTexture2D = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromGLTexture3D = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceIDsFromVA_APIMediaAdapterINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateFromVA_APIMediaSurfaceINTEL = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueAcquireVA_APIMediaSurfacesINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReleaseVA_APIMediaSurfacesINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clHostMemAllocINTEL = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clDeviceMemAllocINTEL = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSharedMemAllocINTEL = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clMemFreeINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clMemBlockingFreeINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetMemAllocInfoINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetKernelArgMemPointerINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMemsetINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMemFillINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMemcpyINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMigrateMemINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMemAdviseINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateBufferWithPropertiesINTEL = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_LONG, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateCommandBufferKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clFinalizeCommandBufferKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainCommandBufferKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseCommandBufferKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueCommandBufferKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandBarrierWithWaitListKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandCopyBufferKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandCopyBufferRectKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandCopyBufferToImageKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandCopyImageKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandCopyImageToBufferKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandFillBufferKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandFillImageKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandNDRangeKernelKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandSVMMemcpyKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCommandSVMMemFillKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetCommandBufferInfoKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clUpdateMutableCommandsKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetMutableCommandInfoKHR = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRemapCommandBufferKHR = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetContentSizeBufferPoCL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetPlatformIDs = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetPlatformInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceIDs = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateSubDevices = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainDevice = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseDevice = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetDefaultDeviceCommandQueue = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetDeviceAndHostTimer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetHostTimer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateContext = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateContextFromType = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainContext = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseContext = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetContextInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetContextDestructorCallback = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateCommandQueueWithProperties = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainCommandQueue = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseCommandQueue = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetCommandQueueInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateBuffer = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateBufferWithProperties = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_LONG, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateSubBuffer = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateImage = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(CLImageFormat.LAYOUT), + ValueLayout.ADDRESS.withTargetLayout(CLImageDesc.LAYOUT), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateImageWithProperties = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(CLImageFormat.LAYOUT), + ValueLayout.ADDRESS.withTargetLayout(CLImageDesc.LAYOUT), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreatePipe = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainMemObject = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseMemObject = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSupportedImageFormats = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(CLImageFormat.LAYOUT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetMemObjectInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetImageInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetPipeInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetMemObjectDestructorCallback = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetMemObjectDestructorAPPLE = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSVMAlloc = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT + ); + + public static final FunctionDescriptor DESCRIPTOR$clSVMFree = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateSamplerWithProperties = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainSampler = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseSampler = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSamplerInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateProgramWithSource = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE)), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateProgramWithBinary = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE)), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateProgramWithBuiltInKernels = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateProgramWithIL = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainProgram = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseProgram = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clBuildProgram = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clCompileProgram = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE)), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clLinkProgram = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetProgramReleaseCallback = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetProgramSpecializationConstant = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clUnloadPlatformCompiler = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetProgramInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetProgramBuildInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateKernel = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateKernelsInProgram = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCloneKernel = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainKernel = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseKernel = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetKernelArg = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetKernelArgSVMPointer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetKernelArgDevicePointerEXT = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_LONG + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetKernelExecInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetKernelInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetKernelArgInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetKernelWorkGroupInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetKernelSubGroupInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clWaitForEvents = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetEventInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateUserEvent = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clRetainEvent = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clReleaseEvent = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetUserEventStatus = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetEventCallback = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetEventProfilingInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clFlush = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clFinish = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReadBuffer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReadBufferRect = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueWriteBuffer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueWriteBufferRect = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueFillBuffer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueCopyBuffer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueCopyBufferRect = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReadImage = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueWriteImage = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueFillImage = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueCopyImage = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueCopyImageToBuffer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueCopyBufferToImage = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMapBuffer = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_LONG, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMapImage = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueUnmapMemObject = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMigrateMemObjects = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueNDRangeKernel = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueNativeKernel = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMarkerWithWaitList = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueBarrierWithWaitList = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMFree = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMMemcpy = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMMemFill = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMMap = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMUnmap = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueSVMMigrateMem = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T), + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetExtensionFunctionAddressForPlatform = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE) + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetCommandQueueProperty = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateImage2D = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(CLImageFormat.LAYOUT), + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateImage3D = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(CLImageFormat.LAYOUT), + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueMarker = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueWaitForEvents = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueBarrier = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor DESCRIPTOR$clUnloadCompiler = FunctionDescriptor.of( + ValueLayout.JAVA_INT + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetExtensionFunctionAddress = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateCommandQueue = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCreateSampler = FunctionDescriptor.of( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueTask = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetLayerInfo = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clInitLayer = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetICDLoaderInfoOCLICD = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSupportedGLTextureFormatsINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSupportedDX9MediaSurfaceFormatsINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSupportedD3D10TextureFormatsINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSupportedD3D11TextureFormatsINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetSupportedVA_APIMediaSurfaceFormatsINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_LONG, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(VAImageFormatCLREF.LAYOUT), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_INT) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueReadHostPipeINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clEnqueueWriteHostPipeINTEL = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS) + ); + + public static final FunctionDescriptor DESCRIPTOR$clGetImageRequirementsInfoEXT = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_LONG), + ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS.withTargetLayout(CLImageFormat.LAYOUT), + ValueLayout.ADDRESS.withTargetLayout(CLImageDesc.LAYOUT), + ValueLayout.JAVA_INT, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T) + ); + + public static final FunctionDescriptor DESCRIPTOR$clCancelCommandsIMG = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + NativeLayout.C_SIZE_T + ); + + public static final FunctionDescriptor DESCRIPTOR$clSetPerfHintQCOM = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT + ); + + /// Constructing this class is nonsense so the constructor is made private. + private Descriptors() {} + } +} diff --git a/src/club/doki7/opencl/CLConstants.class b/src/club/doki7/opencl/CLConstants.class new file mode 100644 index 0000000..3291be9 Binary files /dev/null and b/src/club/doki7/opencl/CLConstants.class differ diff --git a/src/club/doki7/opencl/CLConstants.java b/src/club/doki7/opencl/CLConstants.java new file mode 100644 index 0000000..8e069cc --- /dev/null +++ b/src/club/doki7/opencl/CLConstants.java @@ -0,0 +1,1261 @@ +package club.doki7.opencl; + +import club.doki7.ffm.annotation.*; + +public interface CLConstants { + @Unsigned int A = 0x10B1; + @Unsigned int ABGR = 0x10C3; + @Unsigned int ACCELERATOR_CONTEXT_INTEL = 0x4092; + @Unsigned int ACCELERATOR_DESCRIPTOR_INTEL = 0x4090; + @Unsigned int ACCELERATOR_REFERENCE_COUNT_INTEL = 0x4091; + @Unsigned int ACCELERATOR_TYPE_INTEL = 0x4093; + @Unsigned int ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL = 0x0; + @Unsigned int ADAPTER_D3D9EX_KHR = 0x2021; + @Unsigned int ADAPTER_D3D9_KHR = 0x2020; + @Unsigned int ADAPTER_DXVA_KHR = 0x2022; + @Unsigned int ADDRESS_CLAMP = 0x1132; + @Unsigned int ADDRESS_CLAMP_TO_EDGE = 0x1131; + @Unsigned int ADDRESS_MIRRORED_REPEAT = 0x1134; + @Unsigned int ADDRESS_NONE = 0x1130; + @Unsigned int ADDRESS_REPEAT = 0x1133; + @Unsigned int AFFINITY_DOMAIN_L1_CACHE_EXT = 0x1; + @Unsigned int AFFINITY_DOMAIN_L2_CACHE_EXT = 0x2; + @Unsigned int AFFINITY_DOMAIN_L3_CACHE_EXT = 0x3; + @Unsigned int AFFINITY_DOMAIN_L4_CACHE_EXT = 0x4; + @Unsigned int AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT = 0x100; + @Unsigned int AFFINITY_DOMAIN_NUMA_EXT = 0x10; + @Unsigned int ALL_DEVICES_FOR_D3D10_KHR = 0x4013; + @Unsigned int ALL_DEVICES_FOR_D3D11_KHR = 0x401C; + @Unsigned int ALL_DEVICES_FOR_DX9_INTEL = 0x4025; + @Unsigned int ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR = 0x2024; + @Unsigned int ALL_DEVICES_FOR_VA_API_INTEL = 0x4096; + @Unsigned int ARGB = 0x10B7; + @Unsigned int AVC_ME_BIDIR_WEIGHT_HALF_INTEL = 0x20; + @Unsigned int AVC_ME_BIDIR_WEIGHT_QUARTER_INTEL = 0x10; + @Unsigned int AVC_ME_BIDIR_WEIGHT_THIRD_INTEL = 0x15; + @Unsigned int AVC_ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL = 0x30; + @Unsigned int AVC_ME_BIDIR_WEIGHT_TWO_THIRD_INTEL = 0x2B; + @Unsigned int AVC_ME_BLOCK_BASED_SKIP_4x4_INTEL = 0x00; + @Unsigned int AVC_ME_BLOCK_BASED_SKIP_8x8_INTEL = 0x80; + @Unsigned int AVC_ME_BORDER_REACHED_BOTTOM_INTEL = 0x8; + @Unsigned int AVC_ME_BORDER_REACHED_LEFT_INTEL = 0x0; + @Unsigned int AVC_ME_BORDER_REACHED_RIGHT_INTEL = 0x2; + @Unsigned int AVC_ME_BORDER_REACHED_TOP_INTEL = 0x4; + @Unsigned int AVC_ME_CHROMA_PREDICTOR_MODE_DC_INTEL = 0x0; + @Unsigned int AVC_ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL = 0x1; + @Unsigned int AVC_ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL = 0x3; + @Unsigned int AVC_ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL = 0x2; + @Unsigned int AVC_ME_COST_PRECISION_DPEL_INTEL = 0x3; + @Unsigned int AVC_ME_COST_PRECISION_HPEL_INTEL = 0x1; + @Unsigned int AVC_ME_COST_PRECISION_PEL_INTEL = 0x2; + @Unsigned int AVC_ME_COST_PRECISION_QPEL_INTEL = 0x0; + @Unsigned int AVC_ME_FRAME_BACKWARD_INTEL = 0x2; + @Unsigned int AVC_ME_FRAME_DUAL_INTEL = 0x3; + @Unsigned int AVC_ME_FRAME_FORWARD_INTEL = 0x1; + @Unsigned int AVC_ME_INTERLACED_SCAN_BOTTOM_FIELD_INTEL = 0x1; + @Unsigned int AVC_ME_INTERLACED_SCAN_TOP_FIELD_INTEL = 0x0; + @Unsigned int AVC_ME_INTRA_16x16_INTEL = 0x0; + @Unsigned int AVC_ME_INTRA_4x4_INTEL = 0x2; + @Unsigned int AVC_ME_INTRA_8x8_INTEL = 0x1; + @Unsigned int AVC_ME_INTRA_LUMA_PARTITION_MASK_16x16_INTEL = 0x6; + @Unsigned int AVC_ME_INTRA_LUMA_PARTITION_MASK_4x4_INTEL = 0x3; + @Unsigned int AVC_ME_INTRA_LUMA_PARTITION_MASK_8x8_INTEL = 0x5; + @Unsigned int AVC_ME_INTRA_NEIGHBOR_LEFT_MASK_ENABLE_INTEL = 0x60; + @Unsigned int AVC_ME_INTRA_NEIGHBOR_UPPER_LEFT_MASK_ENABLE_INTEL = 0x4; + @Unsigned int AVC_ME_INTRA_NEIGHBOR_UPPER_MASK_ENABLE_INTEL = 0x10; + @Unsigned int AVC_ME_INTRA_NEIGHBOR_UPPER_RIGHT_MASK_ENABLE_INTEL = 0x8; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_DC_INTEL = 0x2; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL = 0x3; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL = 0x4; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL = 0x6; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL = 0x1; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL = 0x8; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_PLANE_INTEL = 0x4; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL = 0x0; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL = 0x7; + @Unsigned int AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL = 0x5; + @Unsigned int AVC_ME_MAJOR_16x16_INTEL = 0x0; + @Unsigned int AVC_ME_MAJOR_16x8_INTEL = 0x1; + @Unsigned int AVC_ME_MAJOR_8x16_INTEL = 0x2; + @Unsigned int AVC_ME_MAJOR_8x8_INTEL = 0x3; + @Unsigned int AVC_ME_MAJOR_BACKWARD_INTEL = 0x1; + @Unsigned int AVC_ME_MAJOR_BIDIRECTIONAL_INTEL = 0x2; + @Unsigned int AVC_ME_MAJOR_FORWARD_INTEL = 0x0; + @Unsigned int AVC_ME_MINOR_4x4_INTEL = 0x3; + @Unsigned int AVC_ME_MINOR_4x8_INTEL = 0x2; + @Unsigned int AVC_ME_MINOR_8x4_INTEL = 0x1; + @Unsigned int AVC_ME_MINOR_8x8_INTEL = 0x0; + @Unsigned int AVC_ME_PARTITION_MASK_16x16_INTEL = 0x7E; + @Unsigned int AVC_ME_PARTITION_MASK_16x8_INTEL = 0x7D; + @Unsigned int AVC_ME_PARTITION_MASK_4x4_INTEL = 0x3F; + @Unsigned int AVC_ME_PARTITION_MASK_4x8_INTEL = 0x5F; + @Unsigned int AVC_ME_PARTITION_MASK_8x16_INTEL = 0x7B; + @Unsigned int AVC_ME_PARTITION_MASK_8x4_INTEL = 0x6F; + @Unsigned int AVC_ME_PARTITION_MASK_8x8_INTEL = 0x77; + @Unsigned int AVC_ME_PARTITION_MASK_ALL_INTEL = 0x0; + @Unsigned int AVC_ME_SAD_ADJUST_MODE_HAAR_INTEL = 0x2; + @Unsigned int AVC_ME_SAD_ADJUST_MODE_NONE_INTEL = 0x0; + @Unsigned int AVC_ME_SEARCH_WINDOW_16x12_RADIUS_INTEL = 0x9; + @Unsigned int AVC_ME_SEARCH_WINDOW_2x2_RADIUS_INTEL = 0xa; + @Unsigned int AVC_ME_SEARCH_WINDOW_4x4_RADIUS_INTEL = 0x2; + @Unsigned int AVC_ME_SEARCH_WINDOW_CUSTOM_INTEL = 0x8; + @Unsigned int AVC_ME_SEARCH_WINDOW_DIAMOND_INTEL = 0x4; + @Unsigned int AVC_ME_SEARCH_WINDOW_EXHAUSTIVE_INTEL = 0x0; + @Unsigned int AVC_ME_SEARCH_WINDOW_EXTRA_TINY_INTEL = 0x3; + @Unsigned int AVC_ME_SEARCH_WINDOW_LARGE_DIAMOND_INTEL = 0x5; + @Unsigned int AVC_ME_SEARCH_WINDOW_RESERVED0_INTEL = 0x6; + @Unsigned int AVC_ME_SEARCH_WINDOW_RESERVED1_INTEL = 0x7; + @Unsigned int AVC_ME_SEARCH_WINDOW_SMALL_INTEL = 0x1; + @Unsigned int AVC_ME_SEARCH_WINDOW_TINY_INTEL = 0x2; + @Unsigned int AVC_ME_SKIP_BLOCK_PARTITION_16x16_INTEL = 0x0; + @Unsigned int AVC_ME_SKIP_BLOCK_PARTITION_8x8_INTEL = 0x4000; + @Unsigned int AVC_ME_SLICE_TYPE_BPRED_INTEL = 0x1; + @Unsigned int AVC_ME_SLICE_TYPE_INTRA_INTEL = 0x2; + @Unsigned int AVC_ME_SLICE_TYPE_PRED_INTEL = 0x0; + @Unsigned int AVC_ME_SUBPIXEL_MODE_HPEL_INTEL = 0x1; + @Unsigned int AVC_ME_SUBPIXEL_MODE_INTEGER_INTEL = 0x0; + @Unsigned int AVC_ME_SUBPIXEL_MODE_QPEL_INTEL = 0x3; + @Unsigned int AVC_ME_VERSION_0_INTEL = 0x0; + @Unsigned int AVC_ME_VERSION_1_INTEL = 0x1; + @Unsigned int BGRA = 0x10B6; + @Unsigned int BUFFER_CREATE_TYPE_REGION = 0x1220; + @Unsigned int BUILD_SUCCESS = 0; + @Unsigned int CGL_SHAREGROUP_KHR = 0x200C; + @Unsigned int CHAR_BIT = 8; + @Unsigned int COMMAND_ACQUIRE_D3D10_OBJECTS_KHR = 0x4017; + @Unsigned int COMMAND_ACQUIRE_D3D11_OBJECTS_KHR = 0x4020; + @Unsigned int COMMAND_ACQUIRE_D3D9_OBJECTS_INTEL = 0x402A; + @Unsigned int COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR = 0x202B; + @Unsigned int COMMAND_ACQUIRE_DX9_OBJECTS_INTEL = 0x402A; + @Unsigned int COMMAND_ACQUIRE_EGL_OBJECTS_KHR = 0x202D; + @Unsigned int COMMAND_ACQUIRE_EXTERNAL_MEM_OBJECTS_KHR = 0x2047; + @Unsigned int COMMAND_ACQUIRE_GL_OBJECTS = 0x11FF; + @Unsigned int COMMAND_ACQUIRE_GRALLOC_OBJECTS_IMG = 0x40D2; + @Unsigned int COMMAND_ACQUIRE_VA_API_MEDIA_SURFACES_INTEL = 0x409A; + @Unsigned int COMMAND_BARRIER = 0x1205; + @Unsigned int COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR = 0x2; + @Unsigned int COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR = 0x1; + @Unsigned int COMMAND_BUFFER_CAPABILITY_MULTIPLE_QUEUE_KHR = 0x10; + @Unsigned int COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR = 0x4; + @Unsigned int COMMAND_BUFFER_CONTEXT_KHR = 0x1299; + @Unsigned int COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR = 0x4; + @Unsigned int COMMAND_BUFFER_FLAGS_KHR = 0x1293; + @Unsigned int COMMAND_BUFFER_MUTABLE_DISPATCH_ASSERTS_KHR = 0x12B7; + @Unsigned int COMMAND_BUFFER_MUTABLE_KHR = 0x2; + @Unsigned int COMMAND_BUFFER_NUM_QUEUES_KHR = 0x1295; + @Unsigned int COMMAND_BUFFER_PLATFORM_AUTOMATIC_REMAP_KHR = 0x4; + @Unsigned int COMMAND_BUFFER_PLATFORM_REMAP_QUEUES_KHR = 0x2; + @Unsigned int COMMAND_BUFFER_PLATFORM_UNIVERSAL_SYNC_KHR = 0x1; + @Unsigned int COMMAND_BUFFER_PROPERTIES_ARRAY_KHR = 0x1298; + @Unsigned int COMMAND_BUFFER_QUEUES_KHR = 0x1294; + @Unsigned int COMMAND_BUFFER_REFERENCE_COUNT_KHR = 0x1296; + @Unsigned int COMMAND_BUFFER_SIMULTANEOUS_USE_KHR = 0x1; + @Unsigned int COMMAND_BUFFER_STATE_EXECUTABLE_KHR = 1; + @Unsigned int COMMAND_BUFFER_STATE_KHR = 0x1297; + @Unsigned int COMMAND_BUFFER_STATE_PENDING_KHR = 2; + @Unsigned int COMMAND_BUFFER_STATE_RECORDING_KHR = 0; + @Unsigned int COMMAND_COMMAND_BUFFER_KHR = 0x12A8; + @Unsigned int COMMAND_COPY_BUFFER = 0x11F5; + @Unsigned int COMMAND_COPY_BUFFER_RECT = 0x1203; + @Unsigned int COMMAND_COPY_BUFFER_TO_IMAGE = 0x11FA; + @Unsigned int COMMAND_COPY_IMAGE = 0x11F8; + @Unsigned int COMMAND_COPY_IMAGE_TO_BUFFER = 0x11F9; + @Unsigned int COMMAND_EGL_FENCE_SYNC_OBJECT_KHR = 0x202F; + @Unsigned int COMMAND_FILL_BUFFER = 0x1207; + @Unsigned int COMMAND_FILL_IMAGE = 0x1208; + @Unsigned int COMMAND_GENERATE_MIPMAP_IMG = 0x40D6; + @Unsigned int COMMAND_GL_FENCE_SYNC_OBJECT_KHR = 0x200D; + @Unsigned int COMMAND_MAP_BUFFER = 0x11FB; + @Unsigned int COMMAND_MAP_IMAGE = 0x11FC; + @Unsigned int COMMAND_MARKER = 0x11FE; + @Unsigned int COMMAND_MEMADVISE_INTEL = 0x4207; + @Unsigned int COMMAND_MEMCPY_INTEL = 0x4205; + @Unsigned int COMMAND_MEMFILL_INTEL = 0x4204; + @Unsigned int COMMAND_MIGRATEMEM_INTEL = 0x4206; + @Unsigned int COMMAND_MIGRATE_MEM_OBJECTS = 0x1206; + @Unsigned int COMMAND_MIGRATE_MEM_OBJECT_EXT = 0x4040; + @Unsigned int COMMAND_NATIVE_KERNEL = 0x11F2; + @Unsigned int COMMAND_NDRANGE_KERNEL = 0x11F0; + @Unsigned int COMMAND_READ_BUFFER = 0x11F3; + @Unsigned int COMMAND_READ_BUFFER_RECT = 0x1201; + @Unsigned int COMMAND_READ_HOST_PIPE_INTEL = 0x4214; + @Unsigned int COMMAND_READ_IMAGE = 0x11F6; + @Unsigned int COMMAND_RELEASE_D3D10_OBJECTS_KHR = 0x4018; + @Unsigned int COMMAND_RELEASE_D3D11_OBJECTS_KHR = 0x4021; + @Unsigned int COMMAND_RELEASE_D3D9_OBJECTS_INTEL = 0x402B; + @Unsigned int COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR = 0x202C; + @Unsigned int COMMAND_RELEASE_DX9_OBJECTS_INTEL = 0x402B; + @Unsigned int COMMAND_RELEASE_EGL_OBJECTS_KHR = 0x202E; + @Unsigned int COMMAND_RELEASE_EXTERNAL_MEM_OBJECTS_KHR = 0x2048; + @Unsigned int COMMAND_RELEASE_GL_OBJECTS = 0x1200; + @Unsigned int COMMAND_RELEASE_GRALLOC_OBJECTS_IMG = 0x40D3; + @Unsigned int COMMAND_RELEASE_VA_API_MEDIA_SURFACES_INTEL = 0x409B; + @Unsigned int COMMAND_SEMAPHORE_SIGNAL_KHR = 0x2043; + @Unsigned int COMMAND_SEMAPHORE_WAIT_KHR = 0x2042; + @Unsigned int COMMAND_SVM_FREE = 0x1209; + @Unsigned int COMMAND_SVM_FREE_ARM = 0x40BA; + @Unsigned int COMMAND_SVM_MAP = 0x120C; + @Unsigned int COMMAND_SVM_MAP_ARM = 0x40BD; + @Unsigned int COMMAND_SVM_MEMCPY = 0x120A; + @Unsigned int COMMAND_SVM_MEMCPY_ARM = 0x40BB; + @Unsigned int COMMAND_SVM_MEMFILL = 0x120B; + @Unsigned int COMMAND_SVM_MEMFILL_ARM = 0x40BC; + @Unsigned int COMMAND_SVM_MIGRATE_MEM = 0x120E; + @Unsigned int COMMAND_SVM_UNMAP = 0x120D; + @Unsigned int COMMAND_SVM_UNMAP_ARM = 0x40BE; + @Unsigned int COMMAND_TASK = 0x11F1; + @Unsigned int COMMAND_TERMINATION_COMPLETION_ARM = 0; + @Unsigned int COMMAND_TERMINATION_CONTROLLED_FAILURE_ARM = 2; + @Unsigned int COMMAND_TERMINATION_CONTROLLED_SUCCESS_ARM = 1; + @Unsigned int COMMAND_TERMINATION_ERROR_ARM = 3; + @Unsigned int COMMAND_UNMAP_MEM_OBJECT = 0x11FD; + @Unsigned int COMMAND_USER = 0x1204; + @Unsigned int COMMAND_WRITE_BUFFER = 0x11F4; + @Unsigned int COMMAND_WRITE_BUFFER_RECT = 0x1202; + @Unsigned int COMMAND_WRITE_HOST_PIPE_INTEL = 0x4215; + @Unsigned int COMMAND_WRITE_IMAGE = 0x11F7; + @Unsigned int COMPLETE = 0x0; + @Unsigned int CONTEXT_ADAPTER_D3D9EX_KHR = 0x2026; + @Unsigned int CONTEXT_ADAPTER_D3D9_KHR = 0x2025; + @Unsigned int CONTEXT_ADAPTER_DXVA_KHR = 0x2027; + @Unsigned int CONTEXT_D3D10_DEVICE_KHR = 0x4014; + @Unsigned int CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR = 0x402C; + @Unsigned int CONTEXT_D3D11_DEVICE_KHR = 0x401D; + @Unsigned int CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR = 0x402D; + @Unsigned int CONTEXT_D3D9EX_DEVICE_INTEL = 0x4072; + @Unsigned int CONTEXT_D3D9_DEVICE_INTEL = 0x4026; + @Unsigned int CONTEXT_DEVICES = 0x1081; + @Unsigned int CONTEXT_DIAGNOSTICS_LEVEL_ALL_INTEL = 0xff; + @Unsigned int CONTEXT_DIAGNOSTICS_LEVEL_BAD_INTEL = 0x2; + @Unsigned int CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL = 0x1; + @Unsigned int CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL = 0x4; + @Unsigned int CONTEXT_DXVA_DEVICE_INTEL = 0x4073; + @Unsigned int CONTEXT_INTEROP_USER_SYNC = 0x1085; + @Unsigned int CONTEXT_MEMORY_INITIALIZE_KHR = 0x2030; + @Unsigned int CONTEXT_MEMORY_INITIALIZE_LOCAL_KHR = 0x1; + @Unsigned int CONTEXT_MEMORY_INITIALIZE_PRIVATE_KHR = 0x2; + @Unsigned int CONTEXT_NUM_DEVICES = 0x1083; + @Unsigned int CONTEXT_PERF_HINT_QCOM = 0x40C2; + @Unsigned int CONTEXT_PLATFORM = 0x1084; + @Unsigned int CONTEXT_PROPERTIES = 0x1082; + @Unsigned int CONTEXT_REFERENCE_COUNT = 0x1080; + @Unsigned int CONTEXT_SHOW_DIAGNOSTICS_INTEL = 0x4106; + @Unsigned int CONTEXT_TERMINATE_KHR = 0x2032; + @Unsigned int CONTEXT_VA_API_DISPLAY_INTEL = 0x4097; + @Unsigned int CURRENT_DEVICE_FOR_GL_CONTEXT_KHR = 0x2006; + @Unsigned int D3D10_DEVICE_KHR = 0x4010; + @Unsigned int D3D10_DXGI_ADAPTER_KHR = 0x4011; + @Unsigned int D3D11_DEVICE_KHR = 0x4019; + @Unsigned int D3D11_DXGI_ADAPTER_KHR = 0x401A; + @Unsigned int D3D9EX_DEVICE_INTEL = 0x4070; + @Unsigned int D3D9_DEVICE_INTEL = 0x4022; + @Unsigned int DBL_DIG = 15; + @Unsigned int DBL_MANT_DIG = 53; + @Unsigned int DBL_RADIX = 2; + @Unsigned int DEPTH = 0x10BD; + @Unsigned int DEPTH_STENCIL = 0x10BE; + @Unsigned int DEVICES_FOR_GL_CONTEXT_KHR = 0x2007; + @Unsigned int DEVICE_ADDRESS_BITS = 0x100D; + @Unsigned int DEVICE_AFFINITY_DOMAINS_EXT = 0x4056; + @Unsigned int DEVICE_AFFINITY_DOMAIN_L1_CACHE = 0x10; + @Unsigned int DEVICE_AFFINITY_DOMAIN_L2_CACHE = 0x8; + @Unsigned int DEVICE_AFFINITY_DOMAIN_L3_CACHE = 0x4; + @Unsigned int DEVICE_AFFINITY_DOMAIN_L4_CACHE = 0x2; + @Unsigned int DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = 0x20; + @Unsigned int DEVICE_AFFINITY_DOMAIN_NUMA = 0x1; + @Unsigned int DEVICE_ATOMIC_FENCE_CAPABILITIES = 0x1064; + @Unsigned int DEVICE_ATOMIC_MEMORY_CAPABILITIES = 0x1063; + @Unsigned int DEVICE_ATOMIC_ORDER_ACQ_REL = 0x2; + @Unsigned int DEVICE_ATOMIC_ORDER_RELAXED = 0x1; + @Unsigned int DEVICE_ATOMIC_ORDER_SEQ_CST = 0x4; + @Unsigned int DEVICE_ATOMIC_SCOPE_ALL_DEVICES = 0x40; + @Unsigned int DEVICE_ATOMIC_SCOPE_DEVICE = 0x20; + @Unsigned int DEVICE_ATOMIC_SCOPE_WORK_GROUP = 0x10; + @Unsigned int DEVICE_ATOMIC_SCOPE_WORK_ITEM = 0x8; + @Unsigned int DEVICE_AVAILABLE = 0x1027; + @Unsigned int DEVICE_AVAILABLE_ASYNC_QUEUES_AMD = 0x404C; + @Unsigned int DEVICE_AVC_ME_SUPPORTS_PREEMPTION_INTEL = 0x410D; + @Unsigned int DEVICE_AVC_ME_SUPPORTS_TEXTURE_SAMPLER_USE_INTEL = 0x410C; + @Unsigned int DEVICE_AVC_ME_VERSION_INTEL = 0x410B; + @Unsigned int DEVICE_BOARD_NAME_AMD = 0x4038; + @Unsigned int DEVICE_BUILT_IN_KERNELS = 0x103F; + @Unsigned int DEVICE_BUILT_IN_KERNELS_WITH_VERSION = 0x1062; + @Unsigned int DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR = 0x1062; + @Unsigned int DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR = 0x12A9; + @Unsigned int DEVICE_COMMAND_BUFFER_NUM_SYNC_DEVICES_KHR = 0x12AB; + @Unsigned int DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR = 0x12AA; + @Unsigned int DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR = 0x129A; + @Unsigned int DEVICE_COMMAND_BUFFER_SYNC_DEVICES_KHR = 0x12AC; + @Unsigned int DEVICE_COMPILER_AVAILABLE = 0x1028; + @Unsigned int DEVICE_COMPUTE_CAPABILITY_MAJOR_NV = 0x4000; + @Unsigned int DEVICE_COMPUTE_CAPABILITY_MINOR_NV = 0x4001; + @Unsigned int DEVICE_COMPUTE_UNITS_BITFIELD_ARM = 0x40BF; + @Unsigned int DEVICE_CONTROLLED_TERMINATION_CAPABILITIES_ARM = 0x41EE; + @Unsigned int DEVICE_CONTROLLED_TERMINATION_FAILURE_ARM = 0x2; + @Unsigned int DEVICE_CONTROLLED_TERMINATION_QUERY_ARM = 0x4; + @Unsigned int DEVICE_CONTROLLED_TERMINATION_SUCCESS_ARM = 0x1; + @Unsigned int DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL = 0x4193; + @Unsigned int DEVICE_CXX_FOR_OPENCL_NUMERIC_VERSION_EXT = 0x4230; + @Unsigned int DEVICE_DEVICE_ENQUEUE_CAPABILITIES = 0x1070; + @Unsigned int DEVICE_DEVICE_MEM_CAPABILITIES_INTEL = 0x4191; + @Unsigned int DEVICE_DOUBLE_FP_ATOMIC_CAPABILITIES_EXT = 0x4232; + @Unsigned int DEVICE_DOUBLE_FP_CONFIG = 0x1032; + @Unsigned int DEVICE_ENDIAN_LITTLE = 0x1026; + @Unsigned int DEVICE_ERROR_CORRECTION_SUPPORT = 0x1024; + @Unsigned int DEVICE_EXECUTION_CAPABILITIES = 0x1029; + @Unsigned int DEVICE_EXTENSIONS = 0x1030; + @Unsigned int DEVICE_EXTENSIONS_WITH_VERSION = 0x1060; + @Unsigned int DEVICE_EXTENSIONS_WITH_VERSION_KHR = 0x1060; + @Unsigned int DEVICE_EXTERNAL_MEMORY_IMPORT_ASSUME_LINEAR_IMAGES_HANDLE_TYPES_KHR = 0x2052; + @Unsigned int DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR = 0x204F; + @Unsigned int DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM = 0x40A0; + @Unsigned int DEVICE_FEATURE_CAPABILITIES_INTEL = 0x4256; + @Unsigned int DEVICE_FEATURE_FLAG_DP4A_INTEL = 0x1; + @Unsigned int DEVICE_FEATURE_FLAG_DPAS_INTEL = 0x2; + @Unsigned int DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT = 0x1069; + @Unsigned int DEVICE_GFXIP_MAJOR_AMD = 0x404A; + @Unsigned int DEVICE_GFXIP_MINOR_AMD = 0x404B; + @Unsigned int DEVICE_GLOBAL_FP_ATOMIC_ADD_EXT = 0x2; + @Unsigned int DEVICE_GLOBAL_FP_ATOMIC_LOAD_STORE_EXT = 0x1; + @Unsigned int DEVICE_GLOBAL_FP_ATOMIC_MIN_MAX_EXT = 0x4; + @Unsigned int DEVICE_GLOBAL_FREE_MEMORY_AMD = 0x4039; + @Unsigned int DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 0x101D; + @Unsigned int DEVICE_GLOBAL_MEM_CACHE_SIZE = 0x101E; + @Unsigned int DEVICE_GLOBAL_MEM_CACHE_TYPE = 0x101C; + @Unsigned int DEVICE_GLOBAL_MEM_CHANNELS_AMD = 0x4044; + @Unsigned int DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD = 0x4045; + @Unsigned int DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD = 0x4046; + @Unsigned int DEVICE_GLOBAL_MEM_SIZE = 0x101F; + @Unsigned int DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE = 0x1054; + @Unsigned int DEVICE_GPU_OVERLAP_NV = 0x4004; + @Unsigned int DEVICE_HALF_FP_ATOMIC_CAPABILITIES_EXT = 0x4233; + @Unsigned int DEVICE_HALF_FP_CONFIG = 0x1033; + @Unsigned int DEVICE_HOST_MEM_CAPABILITIES_INTEL = 0x4190; + @Unsigned int DEVICE_HOST_UNIFIED_MEMORY = 0x1035; + @Unsigned int DEVICE_ID_INTEL = 0x4251; + @Unsigned int DEVICE_ILS_WITH_VERSION = 0x1061; + @Unsigned int DEVICE_ILS_WITH_VERSION_KHR = 0x1061; + @Unsigned int DEVICE_IL_VERSION = 0x105B; + @Unsigned int DEVICE_IL_VERSION_KHR = 0x105B; + @Unsigned int DEVICE_IMAGE2D_MAX_HEIGHT = 0x1012; + @Unsigned int DEVICE_IMAGE2D_MAX_WIDTH = 0x1011; + @Unsigned int DEVICE_IMAGE3D_MAX_DEPTH = 0x1015; + @Unsigned int DEVICE_IMAGE3D_MAX_HEIGHT = 0x1014; + @Unsigned int DEVICE_IMAGE3D_MAX_WIDTH = 0x1013; + @Unsigned int DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT = 0x104B; + @Unsigned int DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR = 0x104B; + @Unsigned int DEVICE_IMAGE_MAX_ARRAY_SIZE = 0x1041; + @Unsigned int DEVICE_IMAGE_MAX_BUFFER_SIZE = 0x1040; + @Unsigned int DEVICE_IMAGE_PITCH_ALIGNMENT = 0x104A; + @Unsigned int DEVICE_IMAGE_PITCH_ALIGNMENT_KHR = 0x104A; + @Unsigned int DEVICE_IMAGE_SUPPORT = 0x1016; + @Unsigned int DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR = 0x1075; + @Unsigned int DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR = 0x1074; + @Unsigned int DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR = 0x1073; + @Unsigned int DEVICE_INTEGER_DOT_PRODUCT_INPUT_4x8BIT_KHR = 0x2; + @Unsigned int DEVICE_INTEGER_DOT_PRODUCT_INPUT_4x8BIT_PACKED_KHR = 0x1; + @Unsigned int DEVICE_INTEGRATED_MEMORY_NV = 0x4006; + @Unsigned int DEVICE_IP_VERSION_INTEL = 0x4250; + @Unsigned int DEVICE_JOB_SLOTS_ARM = 0x41E0; + @Unsigned int DEVICE_KERNEL_CLOCK_CAPABILITIES_KHR = 0x1076; + @Unsigned int DEVICE_KERNEL_CLOCK_SCOPE_DEVICE_KHR = 0x1; + @Unsigned int DEVICE_KERNEL_CLOCK_SCOPE_SUB_GROUP_KHR = 0x4; + @Unsigned int DEVICE_KERNEL_CLOCK_SCOPE_WORK_GROUP_KHR = 0x2; + @Unsigned int DEVICE_KERNEL_EXEC_TIMEOUT_NV = 0x4005; + @Unsigned int DEVICE_LATEST_CONFORMANCE_VERSION_PASSED = 0x1072; + @Unsigned int DEVICE_LINKER_AVAILABLE = 0x103E; + @Unsigned int DEVICE_LOCAL_FP_ATOMIC_ADD_EXT = 0x20000; + @Unsigned int DEVICE_LOCAL_FP_ATOMIC_LOAD_STORE_EXT = 0x10000; + @Unsigned int DEVICE_LOCAL_FP_ATOMIC_MIN_MAX_EXT = 0x40000; + @Unsigned int DEVICE_LOCAL_MEM_BANKS_AMD = 0x4048; + @Unsigned int DEVICE_LOCAL_MEM_SIZE = 0x1023; + @Unsigned int DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD = 0x4047; + @Unsigned int DEVICE_LOCAL_MEM_TYPE = 0x1022; + @Unsigned int DEVICE_LUID_KHR = 0x106D; + @Unsigned int DEVICE_LUID_VALID_KHR = 0x106C; + @Unsigned int DEVICE_MAX_CLOCK_FREQUENCY = 0x100C; + @Unsigned int DEVICE_MAX_COMPUTE_UNITS = 0x1002; + @Unsigned int DEVICE_MAX_CONSTANT_ARGS = 0x1021; + @Unsigned int DEVICE_MAX_CONSTANT_BUFFER_SIZE = 0x1020; + @Unsigned int DEVICE_MAX_GLOBAL_VARIABLE_SIZE = 0x104D; + @Unsigned int DEVICE_MAX_HOST_READ_PIPES_INTEL = 0x4211; + @Unsigned int DEVICE_MAX_HOST_WRITE_PIPES_INTEL = 0x4212; + @Unsigned int DEVICE_MAX_MEM_ALLOC_SIZE = 0x1010; + @Unsigned int DEVICE_MAX_NAMED_BARRIER_COUNT_KHR = 0x2035; + @Unsigned int DEVICE_MAX_NUM_SUB_GROUPS = 0x105C; + @Unsigned int DEVICE_MAX_ON_DEVICE_EVENTS = 0x1052; + @Unsigned int DEVICE_MAX_ON_DEVICE_QUEUES = 0x1051; + @Unsigned int DEVICE_MAX_PARAMETER_SIZE = 0x1017; + @Unsigned int DEVICE_MAX_PIPE_ARGS = 0x1055; + @Unsigned int DEVICE_MAX_READ_IMAGE_ARGS = 0x100E; + @Unsigned int DEVICE_MAX_READ_WRITE_IMAGE_ARGS = 0x104C; + @Unsigned int DEVICE_MAX_SAMPLERS = 0x1018; + @Unsigned int DEVICE_MAX_WARP_COUNT_ARM = 0x41EA; + @Unsigned int DEVICE_MAX_WORK_GROUP_SIZE = 0x1004; + @Unsigned int DEVICE_MAX_WORK_GROUP_SIZE_AMD = 0x4031; + @Unsigned int DEVICE_MAX_WORK_ITEM_DIMENSIONS = 0x1003; + @Unsigned int DEVICE_MAX_WORK_ITEM_SIZES = 0x1005; + @Unsigned int DEVICE_MAX_WRITE_IMAGE_ARGS = 0x100F; + @Unsigned int DEVICE_MEMORY_CAPABILITIES_IMG = 0x40D8; + @Unsigned int DEVICE_MEM_BASE_ADDR_ALIGN = 0x1019; + @Unsigned int DEVICE_ME_VERSION_INTEL = 0x407E; + @Unsigned int DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 0x101A; + @Unsigned int DEVICE_MUTABLE_DISPATCH_CAPABILITIES_KHR = 0x12B0; + @Unsigned int DEVICE_NAME = 0x102B; + @Unsigned int DEVICE_NATIVE_VECTOR_WIDTH_CHAR = 0x1036; + @Unsigned int DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE = 0x103B; + @Unsigned int DEVICE_NATIVE_VECTOR_WIDTH_FLOAT = 0x103A; + @Unsigned int DEVICE_NATIVE_VECTOR_WIDTH_HALF = 0x103C; + @Unsigned int DEVICE_NATIVE_VECTOR_WIDTH_INT = 0x1038; + @Unsigned int DEVICE_NATIVE_VECTOR_WIDTH_LONG = 0x1039; + @Unsigned int DEVICE_NATIVE_VECTOR_WIDTH_SHORT = 0x1037; + @Unsigned int DEVICE_NODE_MASK_KHR = 0x106E; + @Unsigned int DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT = 0x1065; + @Unsigned int DEVICE_NUMERIC_VERSION = 0x105E; + @Unsigned int DEVICE_NUMERIC_VERSION_KHR = 0x105E; + @Unsigned int DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL = 0x4254; + @Unsigned int DEVICE_NUM_SIMULTANEOUS_INTEROPS_INTEL = 0x4105; + @Unsigned int DEVICE_NUM_SLICES_INTEL = 0x4252; + @Unsigned int DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL = 0x4253; + @Unsigned int DEVICE_NUM_THREADS_PER_EU_INTEL = 0x4255; + @Unsigned int DEVICE_OPENCL_C_ALL_VERSIONS = 0x1066; + @Unsigned int DEVICE_OPENCL_C_FEATURES = 0x106F; + @Unsigned int DEVICE_OPENCL_C_NUMERIC_VERSION_KHR = 0x105F; + @Unsigned int DEVICE_OPENCL_C_VERSION = 0x103D; + @Unsigned int DEVICE_PAGE_SIZE_QCOM = 0x40A1; + @Unsigned int DEVICE_PARENT_DEVICE = 0x1042; + @Unsigned int DEVICE_PARENT_DEVICE_EXT = 0x4054; + @Unsigned int DEVICE_PARTITION_AFFINITY_DOMAIN = 0x1045; + @Unsigned int DEVICE_PARTITION_BY_AFFINITY_DOMAIN = 0x1088; + @Unsigned int DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT = 0x4053; + @Unsigned int DEVICE_PARTITION_BY_COUNTS = 0x1087; + @Unsigned int DEVICE_PARTITION_BY_COUNTS_EXT = 0x4051; + @Unsigned int DEVICE_PARTITION_BY_COUNTS_LIST_END = 0x0; + @Unsigned int DEVICE_PARTITION_BY_NAMES_EXT = 0x4052; + @Unsigned int DEVICE_PARTITION_BY_NAMES_INTEL = 0x4052; + @Unsigned int DEVICE_PARTITION_EQUALLY = 0x1086; + @Unsigned int DEVICE_PARTITION_EQUALLY_EXT = 0x4050; + @Unsigned int DEVICE_PARTITION_MAX_SUB_DEVICES = 0x1043; + @Unsigned int DEVICE_PARTITION_PROPERTIES = 0x1044; + @Unsigned int DEVICE_PARTITION_STYLE_EXT = 0x4058; + @Unsigned int DEVICE_PARTITION_TYPE = 0x1046; + @Unsigned int DEVICE_PARTITION_TYPES_EXT = 0x4055; + @Unsigned int DEVICE_PCIE_ID_AMD = 0x4034; + @Unsigned int DEVICE_PCI_BUS_INFO_KHR = 0x410F; + @Unsigned int DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS = 0x1056; + @Unsigned int DEVICE_PIPE_MAX_PACKET_SIZE = 0x1057; + @Unsigned int DEVICE_PIPE_SUPPORT = 0x1071; + @Unsigned int DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL = 0x417F; + @Unsigned int DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL = 0x417E; + @Unsigned int DEVICE_PLATFORM = 0x1031; + @Unsigned int DEVICE_PREFERRED_CONSTANT_BUFFER_SIZE_AMD = 0x4033; + @Unsigned int DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT = 0x1059; + @Unsigned int DEVICE_PREFERRED_INTEROP_USER_SYNC = 0x1048; + @Unsigned int DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT = 0x105A; + @Unsigned int DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT = 0x1058; + @Unsigned int DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 0x1006; + @Unsigned int DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 0x100B; + @Unsigned int DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 0x100A; + @Unsigned int DEVICE_PREFERRED_VECTOR_WIDTH_HALF = 0x1034; + @Unsigned int DEVICE_PREFERRED_VECTOR_WIDTH_INT = 0x1008; + @Unsigned int DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 0x1009; + @Unsigned int DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 0x1007; + @Unsigned int DEVICE_PREFERRED_WORK_GROUP_SIZE_AMD = 0x4030; + @Unsigned int DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x1067; + @Unsigned int DEVICE_PRINTF_BUFFER_SIZE = 0x1049; + @Unsigned int DEVICE_PROFILE = 0x102E; + @Unsigned int DEVICE_PROFILING_TIMER_OFFSET_AMD = 0x4036; + @Unsigned int DEVICE_PROFILING_TIMER_RESOLUTION = 0x1025; + @Unsigned int DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL = 0x418B; + @Unsigned int DEVICE_QUEUE_ON_DEVICE_MAX_SIZE = 0x1050; + @Unsigned int DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE = 0x104F; + @Unsigned int DEVICE_QUEUE_ON_DEVICE_PROPERTIES = 0x104E; + @Unsigned int DEVICE_QUEUE_ON_HOST_PROPERTIES = 0x102A; + @Unsigned int DEVICE_QUEUE_PROPERTIES = 0x102A; + @Unsigned int DEVICE_QUEUE_REPLACEABLE_DEFAULT = 0x2; + @Unsigned int DEVICE_QUEUE_SUPPORTED = 0x1; + @Unsigned int DEVICE_REFERENCE_COUNT = 0x1047; + @Unsigned int DEVICE_REFERENCE_COUNT_EXT = 0x4057; + @Unsigned int DEVICE_REGISTERS_PER_BLOCK_NV = 0x4002; + @Unsigned int DEVICE_SCHEDULING_COMPUTE_UNIT_BATCH_QUEUE_SIZE_ARM = 0x40; + @Unsigned int DEVICE_SCHEDULING_COMPUTE_UNIT_LIMIT_ARM = 0x80; + @Unsigned int DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM = 0x41E4; + @Unsigned int DEVICE_SCHEDULING_DEFERRED_FLUSH_ARM = 0x8; + @Unsigned int DEVICE_SCHEDULING_KERNEL_BATCHING_ARM = 0x1; + @Unsigned int DEVICE_SCHEDULING_REGISTER_ALLOCATION_ARM = 0x10; + @Unsigned int DEVICE_SCHEDULING_WARP_THROTTLING_ARM = 0x20; + @Unsigned int DEVICE_SCHEDULING_WORKGROUP_BATCH_SIZE_ARM = 0x2; + @Unsigned int DEVICE_SCHEDULING_WORKGROUP_BATCH_SIZE_MODIFIER_ARM = 0x4; + @Unsigned int DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR = 0x204E; + @Unsigned int DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR = 0x204D; + @Unsigned int DEVICE_SEMAPHORE_TYPES_KHR = 0x204C; + @Unsigned int DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL = 0x4194; + @Unsigned int DEVICE_SIMD_INSTRUCTION_WIDTH_AMD = 0x4042; + @Unsigned int DEVICE_SIMD_PER_COMPUTE_UNIT_AMD = 0x4040; + @Unsigned int DEVICE_SIMD_WIDTH_AMD = 0x4041; + @Unsigned int DEVICE_SIMULTANEOUS_INTEROPS_INTEL = 0x4104; + @Unsigned int DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL = 0x4192; + @Unsigned int DEVICE_SINGLE_FP_ATOMIC_CAPABILITIES_EXT = 0x4231; + @Unsigned int DEVICE_SINGLE_FP_CONFIG = 0x101B; + @Unsigned int DEVICE_SPIRV_CAPABILITIES_KHR = 0x12BB; + @Unsigned int DEVICE_SPIRV_EXTENDED_INSTRUCTION_SETS_KHR = 0x12B9; + @Unsigned int DEVICE_SPIRV_EXTENSIONS_KHR = 0x12BA; + @Unsigned int DEVICE_SPIR_VERSIONS = 0x40E0; + @Unsigned int DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 0x105D; + @Unsigned int DEVICE_SUB_GROUP_SIZES_INTEL = 0x4108; + @Unsigned int DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM = 0x41EB; + @Unsigned int DEVICE_SVM_ATOMICS = 0x8; + @Unsigned int DEVICE_SVM_ATOMICS_ARM = 0x8; + @Unsigned int DEVICE_SVM_CAPABILITIES = 0x1053; + @Unsigned int DEVICE_SVM_CAPABILITIES_ARM = 0x40B6; + @Unsigned int DEVICE_SVM_COARSE_GRAIN_BUFFER = 0x1; + @Unsigned int DEVICE_SVM_COARSE_GRAIN_BUFFER_ARM = 0x1; + @Unsigned int DEVICE_SVM_FINE_GRAIN_BUFFER = 0x2; + @Unsigned int DEVICE_SVM_FINE_GRAIN_BUFFER_ARM = 0x2; + @Unsigned int DEVICE_SVM_FINE_GRAIN_SYSTEM = 0x4; + @Unsigned int DEVICE_SVM_FINE_GRAIN_SYSTEM_ARM = 0x4; + @Unsigned int DEVICE_TERMINATE_CAPABILITY_CONTEXT_KHR = 0x1; + @Unsigned int DEVICE_TERMINATE_CAPABILITY_KHR = 0x2031; + @Unsigned int DEVICE_THREAD_TRACE_SUPPORTED_AMD = 0x4049; + @Unsigned int DEVICE_TOPOLOGY_AMD = 0x4037; + @Unsigned int DEVICE_TYPE = 0x1000; + @Unsigned int DEVICE_TYPE_ACCELERATOR = 0x8; + @Unsigned int DEVICE_TYPE_ALL = 0xFFFFFFFF; + @Unsigned int DEVICE_TYPE_CPU = 0x2; + @Unsigned int DEVICE_TYPE_CUSTOM = 0x10; + @Unsigned int DEVICE_TYPE_DEFAULT = 0x1; + @Unsigned int DEVICE_TYPE_GPU = 0x4; + @Unsigned int DEVICE_UUID_KHR = 0x106A; + @Unsigned int DEVICE_VENDOR = 0x102C; + @Unsigned int DEVICE_VENDOR_ID = 0x1001; + @Unsigned int DEVICE_VERSION = 0x102F; + @Unsigned int DEVICE_WARP_SIZE_NV = 0x4003; + @Unsigned int DEVICE_WAVEFRONT_WIDTH_AMD = 0x4043; + @Unsigned int DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT = 0x1068; + @Unsigned int DRIVER_UUID_KHR = 0x106B; + @Unsigned int DRIVER_VERSION = 0x102D; + @Unsigned int DXVA_DEVICE_INTEL = 0x4071; + @Unsigned int EGL_DISPLAY_KHR = 0x2009; + @Unsigned int EGL_YUV_PLANE_INTEL = 0x4107; + @Unsigned int EVENT_COMMAND_EXECUTION_STATUS = 0x11D3; + @Unsigned int EVENT_COMMAND_QUEUE = 0x11D0; + @Unsigned int EVENT_COMMAND_TERMINATION_REASON_ARM = 0x41ED; + @Unsigned int EVENT_COMMAND_TYPE = 0x11D1; + @Unsigned int EVENT_CONTEXT = 0x11D4; + @Unsigned int EVENT_REFERENCE_COUNT = 0x11D2; + @Unsigned int EXEC_KERNEL = 0x1; + @Unsigned int EXEC_NATIVE_KERNEL = 0x2; + @Unsigned int EXTERNAL_MEMORY_HANDLE_ANDROID_HARDWARE_BUFFER_KHR = 0x2070; + @Unsigned int EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR = 0x2067; + @Unsigned int EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR = 0x2060; + @Unsigned int EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR = 0x2061; + @Unsigned int EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR = 0x2062; + @Unsigned int EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR = 0x2069; + @Unsigned int FALSE = 0; + @Unsigned int FILTER_LINEAR = 0x1141; + @Unsigned int FILTER_NEAREST = 0x1140; + @Unsigned int FLOAT = 0x10DE; + @Unsigned int FLT_DIG = 6; + @Unsigned int FLT_MANT_DIG = 24; + @Unsigned int FLT_RADIX = 2; + @Unsigned int FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = 0x80; + @Unsigned int FP_DENORM = 0x1; + @Unsigned int FP_FMA = 0x20; + @Unsigned int FP_INF_NAN = 0x2; + @Unsigned int FP_ROUND_TO_INF = 0x10; + @Unsigned int FP_ROUND_TO_NEAREST = 0x4; + @Unsigned int FP_ROUND_TO_ZERO = 0x8; + @Unsigned int FP_SOFT_FLOAT = 0x40; + @Unsigned int GLOBAL = 0x2; + @Unsigned int GLX_DISPLAY_KHR = 0x200A; + @Unsigned int GL_CONTEXT_KHR = 0x2008; + @Unsigned int GL_MIPMAP_LEVEL = 0x2005; + @Unsigned int GL_NUM_SAMPLES = 0x2012; + @Unsigned int GL_OBJECT_BUFFER = 0x2000; + @Unsigned int GL_OBJECT_RENDERBUFFER = 0x2003; + @Unsigned int GL_OBJECT_TEXTURE1D = 0x200F; + @Unsigned int GL_OBJECT_TEXTURE1D_ARRAY = 0x2010; + @Unsigned int GL_OBJECT_TEXTURE2D = 0x2001; + @Unsigned int GL_OBJECT_TEXTURE2D_ARRAY = 0x200E; + @Unsigned int GL_OBJECT_TEXTURE3D = 0x2002; + @Unsigned int GL_OBJECT_TEXTURE_BUFFER = 0x2011; + @Unsigned int GL_TEXTURE_TARGET = 0x2004; + @Unsigned int GRALLOC_RESOURCE_NOT_ACQUIRED_IMG = 0x40D4; + @Unsigned int HALF_DIG = 3; + @Unsigned int HALF_FLOAT = 0x10DD; + @Unsigned int HALF_MANT_DIG = 11; + @Unsigned int HALF_RADIX = 2; + @Unsigned int ICDL_NAME = 3; + @Unsigned int ICDL_OCL_VERSION = 1; + @Unsigned int ICDL_VENDOR = 4; + @Unsigned int ICDL_VERSION = 2; + @Unsigned int IMAGE_ARRAY_SIZE = 0x1117; + @Unsigned int IMAGE_BUFFER = 0x1118; + @Unsigned int IMAGE_D3D10_SUBRESOURCE_KHR = 0x4016; + @Unsigned int IMAGE_D3D11_SUBRESOURCE_KHR = 0x401F; + @Unsigned int IMAGE_DEPTH = 0x1116; + @Unsigned int IMAGE_DX9_MEDIA_PLANE_KHR = 0x202A; + @Unsigned int IMAGE_DX9_PLANE_INTEL = 0x4075; + @Unsigned int IMAGE_ELEMENT_SIZE = 0x1111; + @Unsigned int IMAGE_FORMAT = 0x1110; + @Unsigned int IMAGE_HEIGHT = 0x1115; + @Unsigned int IMAGE_NUM_MIP_LEVELS = 0x1119; + @Unsigned int IMAGE_NUM_SAMPLES = 0x111A; + @Unsigned int IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT = 0x1292; + @Unsigned int IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT = 0x12B6; + @Unsigned int IMAGE_REQUIREMENTS_MAX_DEPTH_EXT = 0x12B5; + @Unsigned int IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT = 0x12B4; + @Unsigned int IMAGE_REQUIREMENTS_MAX_WIDTH_EXT = 0x12B3; + @Unsigned int IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT = 0x1290; + @Unsigned int IMAGE_REQUIREMENTS_SIZE_EXT = 0x12B2; + @Unsigned int IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT = 0x1291; + @Unsigned int IMAGE_ROW_ALIGNMENT_QCOM = 0x40A2; + @Unsigned int IMAGE_ROW_PITCH = 0x1112; + @Unsigned int IMAGE_SLICE_ALIGNMENT_QCOM = 0x40A3; + @Unsigned int IMAGE_SLICE_PITCH = 0x1113; + @Unsigned int IMAGE_VA_API_PLANE_INTEL = 0x4099; + @Unsigned int IMAGE_WIDTH = 0x1114; + @Unsigned int IMPORT_ANDROID_HARDWARE_BUFFER_LAYER_INDEX_ARM = 0x41F0; + @Unsigned int IMPORT_ANDROID_HARDWARE_BUFFER_PLANE_INDEX_ARM = 0x41EF; + @Unsigned int IMPORT_DMA_BUF_DATA_CONSISTENCY_WITH_HOST_ARM = 0x41E3; + @Unsigned int IMPORT_TYPE_ANDROID_HARDWARE_BUFFER_ARM = 0x41E2; + @Unsigned int IMPORT_TYPE_ARM = 0x40B2; + @Unsigned int IMPORT_TYPE_DMA_BUF_ARM = 0x40B4; + @Unsigned int IMPORT_TYPE_HOST_ARM = 0x40B3; + @Unsigned int IMPORT_TYPE_PROTECTED_ARM = 0x40B5; + @Unsigned int INTENSITY = 0x10B8; + @Unsigned int INT_MAX = 2147483647; + @Unsigned int INVALID_GRALLOC_OBJECT_IMG = 0x40D5; + @Unsigned int KERNEL_ARG_ACCESS_NONE = 0x11A3; + @Unsigned int KERNEL_ARG_ACCESS_QUALIFIER = 0x1197; + @Unsigned int KERNEL_ARG_ACCESS_READ_ONLY = 0x11A0; + @Unsigned int KERNEL_ARG_ACCESS_READ_WRITE = 0x11A2; + @Unsigned int KERNEL_ARG_ACCESS_WRITE_ONLY = 0x11A1; + @Unsigned int KERNEL_ARG_ADDRESS_CONSTANT = 0x119D; + @Unsigned int KERNEL_ARG_ADDRESS_GLOBAL = 0x119B; + @Unsigned int KERNEL_ARG_ADDRESS_LOCAL = 0x119C; + @Unsigned int KERNEL_ARG_ADDRESS_PRIVATE = 0x119E; + @Unsigned int KERNEL_ARG_ADDRESS_QUALIFIER = 0x1196; + @Unsigned int KERNEL_ARG_HOST_ACCESSIBLE_PIPE_INTEL = 0x4210; + @Unsigned int KERNEL_ARG_NAME = 0x119A; + @Unsigned int KERNEL_ARG_TYPE_CONST = 0x1; + @Unsigned int KERNEL_ARG_TYPE_NAME = 0x1198; + @Unsigned int KERNEL_ARG_TYPE_NONE = 0; + @Unsigned int KERNEL_ARG_TYPE_PIPE = 0x8; + @Unsigned int KERNEL_ARG_TYPE_QUALIFIER = 0x1199; + @Unsigned int KERNEL_ARG_TYPE_RESTRICT = 0x2; + @Unsigned int KERNEL_ARG_TYPE_VOLATILE = 0x4; + @Unsigned int KERNEL_ATTRIBUTES = 0x1195; + @Unsigned int KERNEL_COMPILE_NUM_SUB_GROUPS = 0x11BA; + @Unsigned int KERNEL_COMPILE_SUB_GROUP_SIZE_INTEL = 0x410A; + @Unsigned int KERNEL_COMPILE_WORK_GROUP_SIZE = 0x11B1; + @Unsigned int KERNEL_CONTEXT = 0x1193; + @Unsigned int KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM = 0x41F1; + @Unsigned int KERNEL_EXEC_INFO_DEVICE_PTRS_EXT = 0x5002; + @Unsigned int KERNEL_EXEC_INFO_INDIRECT_DEVICE_ACCESS_INTEL = 0x4201; + @Unsigned int KERNEL_EXEC_INFO_INDIRECT_HOST_ACCESS_INTEL = 0x4200; + @Unsigned int KERNEL_EXEC_INFO_INDIRECT_SHARED_ACCESS_INTEL = 0x4202; + @Unsigned int KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM = 0x11B7; + @Unsigned int KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM_ARM = 0x40B9; + @Unsigned int KERNEL_EXEC_INFO_SVM_PTRS = 0x11B6; + @Unsigned int KERNEL_EXEC_INFO_SVM_PTRS_ARM = 0x40B8; + @Unsigned int KERNEL_EXEC_INFO_USM_PTRS_INTEL = 0x4203; + @Unsigned int KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM = 0x41E8; + @Unsigned int KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM = 0x41E5; + @Unsigned int KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM = 0x41E6; + @Unsigned int KERNEL_FUNCTION_NAME = 0x1190; + @Unsigned int KERNEL_GLOBAL_WORK_SIZE = 0x11B5; + @Unsigned int KERNEL_LOCAL_MEM_SIZE = 0x11B2; + @Unsigned int KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT = 0x11B8; + @Unsigned int KERNEL_MAX_NUM_SUB_GROUPS = 0x11B9; + @Unsigned int KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE = 0x2033; + @Unsigned int KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR = 0x2033; + @Unsigned int KERNEL_MAX_WARP_COUNT_ARM = 0x41E9; + @Unsigned int KERNEL_NUM_ARGS = 0x1191; + @Unsigned int KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3; + @Unsigned int KERNEL_PRIVATE_MEM_SIZE = 0x11B4; + @Unsigned int KERNEL_PROGRAM = 0x1194; + @Unsigned int KERNEL_REFERENCE_COUNT = 0x1192; + @Unsigned int KERNEL_SPILL_MEM_SIZE_INTEL = 0x4109; + @Unsigned int KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE = 0x2034; + @Unsigned int KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR = 0x2034; + @Unsigned int KERNEL_WORK_GROUP_SIZE = 0x11B0; + @Unsigned int KHRONOS_VENDOR_ID_CODEPLAY = 0x10004; + @Unsigned int KHRONOS_VENDOR_ID_POCL = 0x10006; + @Unsigned int LAYER_API_VERSION = 0x4240; + @Unsigned int LAYER_API_VERSION_100 = 100; + @Unsigned int LAYER_NAME = 0x4241; + @Unsigned int LOCAL = 0x1; + @Unsigned int LUID_SIZE_KHR = 8; + @Unsigned int LUMINANCE = 0x10B9; + @Unsigned int MAP_READ = 0x1; + @Unsigned int MAP_WRITE = 0x2; + @Unsigned int MAP_WRITE_INVALIDATE_REGION = 0x4; + @Unsigned int MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL = 0x2000000; + @Unsigned int MEM_ALLOC_BASE_PTR_INTEL = 0x419B; + @Unsigned int MEM_ALLOC_BUFFER_LOCATION_INTEL = 0x419E; + @Unsigned int MEM_ALLOC_CPU_LOCAL_IMG = 0x8; + @Unsigned int MEM_ALLOC_DEVICE_INTEL = 0x419D; + @Unsigned int MEM_ALLOC_FLAGS_IMG = 0x40D7; + @Unsigned int MEM_ALLOC_FLAGS_INTEL = 0x4195; + @Unsigned int MEM_ALLOC_GPU_CACHED_IMG = 0x4; + @Unsigned int MEM_ALLOC_GPU_LOCAL_IMG = 0x10; + @Unsigned int MEM_ALLOC_GPU_PRIVATE_IMG = 0x20; + @Unsigned int MEM_ALLOC_GPU_WRITE_COMBINE_IMG = 0x2; + @Unsigned int MEM_ALLOC_HOST_PTR = 0x10; + @Unsigned int MEM_ALLOC_INITIAL_PLACEMENT_DEVICE_INTEL = 0x2; + @Unsigned int MEM_ALLOC_INITIAL_PLACEMENT_HOST_INTEL = 0x4; + @Unsigned int MEM_ALLOC_RELAX_REQUIREMENTS_IMG = 0x1; + @Unsigned int MEM_ALLOC_SIZE_INTEL = 0x419C; + @Unsigned int MEM_ALLOC_TYPE_INTEL = 0x419A; + @Unsigned int MEM_ALLOC_WRITE_COMBINED_INTEL = 0x1; + @Unsigned int MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM = 0x40C6; + @Unsigned int MEM_ASSOCIATED_MEMOBJECT = 0x1107; + @Unsigned int MEM_CHANNEL_INTEL = 0x4213; + @Unsigned int MEM_CONTEXT = 0x1106; + @Unsigned int MEM_COPY_HOST_PTR = 0x20; + @Unsigned int MEM_D3D10_RESOURCE_KHR = 0x4015; + @Unsigned int MEM_D3D11_RESOURCE_KHR = 0x401E; + @Unsigned int MEM_DEVICE_ADDRESS_EXT = 0x5001; + @Unsigned int MEM_DEVICE_HANDLE_LIST_END_KHR = 0; + @Unsigned int MEM_DEVICE_HANDLE_LIST_KHR = 0x2051; + @Unsigned int MEM_DEVICE_ID_INTEL = 0x4219; + @Unsigned int MEM_DEVICE_PRIVATE_ADDRESS_EXT = 0x5000; + @Unsigned int MEM_DX9_MEDIA_ADAPTER_TYPE_KHR = 0x2028; + @Unsigned int MEM_DX9_MEDIA_SURFACE_INFO_KHR = 0x2029; + @Unsigned int MEM_DX9_RESOURCE_INTEL = 0x4027; + @Unsigned int MEM_DX9_SHARED_HANDLE_INTEL = 0x4074; + @Unsigned int MEM_EXT_HOST_PTR_QCOM = 0x20000000; + @Unsigned int MEM_FLAGS = 0x1101; + @Unsigned int MEM_FORCE_HOST_MEMORY_INTEL = 0x100000; + @Unsigned int MEM_HOST_IOCOHERENT_QCOM = 0x40A9; + @Unsigned int MEM_HOST_NO_ACCESS = 0x200; + @Unsigned int MEM_HOST_PTR = 0x1103; + @Unsigned int MEM_HOST_READ_ONLY = 0x100; + @Unsigned int MEM_HOST_UNCACHED_QCOM = 0x40A4; + @Unsigned int MEM_HOST_WRITEBACK_QCOM = 0x40A5; + @Unsigned int MEM_HOST_WRITETHROUGH_QCOM = 0x40A6; + @Unsigned int MEM_HOST_WRITE_COMBINING_QCOM = 0x40A7; + @Unsigned int MEM_HOST_WRITE_ONLY = 0x80; + @Unsigned int MEM_IMMUTABLE_EXT = 0x40; + @Unsigned int MEM_ION_HOST_PTR_QCOM = 0x40A8; + @Unsigned int MEM_KERNEL_READ_AND_WRITE = 0x1000; + @Unsigned int MEM_LOCALLY_UNCACHED_RESOURCE_INTEL = 0x4218; + @Unsigned int MEM_MAP_COUNT = 0x1104; + @Unsigned int MEM_NO_ACCESS_INTEL = 0x1000000; + @Unsigned int MEM_OBJECT_BUFFER = 0x10F0; + @Unsigned int MEM_OBJECT_IMAGE1D = 0x10F4; + @Unsigned int MEM_OBJECT_IMAGE1D_ARRAY = 0x10F5; + @Unsigned int MEM_OBJECT_IMAGE1D_BUFFER = 0x10F6; + @Unsigned int MEM_OBJECT_IMAGE2D = 0x10F1; + @Unsigned int MEM_OBJECT_IMAGE2D_ARRAY = 0x10F3; + @Unsigned int MEM_OBJECT_IMAGE3D = 0x10F2; + @Unsigned int MEM_OBJECT_PIPE = 0x10F7; + @Unsigned int MEM_OFFSET = 0x1108; + @Unsigned int MEM_PROPERTIES = 0x110A; + @Unsigned int MEM_READ_ONLY = 0x4; + @Unsigned int MEM_READ_WRITE = 0x1; + @Unsigned int MEM_REFERENCE_COUNT = 0x1105; + @Unsigned int MEM_RESERVED21_INTEL = 0x200000; + @Unsigned int MEM_RESERVED22_INTEL = 0x400000; + @Unsigned int MEM_SIZE = 0x1102; + @Unsigned int MEM_SVM_ATOMICS = 0x800; + @Unsigned int MEM_SVM_ATOMICS_ARM = 0x800; + @Unsigned int MEM_SVM_FINE_GRAIN_BUFFER = 0x400; + @Unsigned int MEM_SVM_FINE_GRAIN_BUFFER_ARM = 0x400; + @Unsigned int MEM_TYPE = 0x1100; + @Unsigned int MEM_TYPE_DEVICE_INTEL = 0x4198; + @Unsigned int MEM_TYPE_HOST_INTEL = 0x4197; + @Unsigned int MEM_TYPE_SHARED_INTEL = 0x4199; + @Unsigned int MEM_TYPE_UNKNOWN_INTEL = 0x4196; + @Unsigned int MEM_USES_SVM_POINTER = 0x1109; + @Unsigned int MEM_USES_SVM_POINTER_ARM = 0x40B7; + @Unsigned int MEM_USE_CACHED_CPU_MEMORY_IMG = 0x8000000; + @Unsigned int MEM_USE_GRALLOC_PTR_IMG = 0x10000000; + @Unsigned int MEM_USE_HOST_PTR = 0x8; + @Unsigned int MEM_USE_UNCACHED_CPU_MEMORY_IMG = 0x4000000; + @Unsigned int MEM_VA_API_MEDIA_SURFACE_INTEL = 0x4098; + @Unsigned int MEM_WRITE_ONLY = 0x2; + @Unsigned int ME_BACKWARD_INPUT_MODE_INTEL = 0x2; + @Unsigned int ME_BIDIRECTION_INPUT_MODE_INTEL = 0x3; + @Unsigned int ME_BIDIR_WEIGHT_HALF_INTEL = 32; + @Unsigned int ME_BIDIR_WEIGHT_QUARTER_INTEL = 16; + @Unsigned int ME_BIDIR_WEIGHT_THIRD_INTEL = 21; + @Unsigned int ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL = 48; + @Unsigned int ME_BIDIR_WEIGHT_TWO_THIRD_INTEL = 43; + @Unsigned int ME_CHROMA_INTRA_PREDICT_ENABLED_INTEL = 0x1; + @Unsigned int ME_CHROMA_PREDICTOR_MODE_DC_INTEL = 0x0; + @Unsigned int ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL = 0x1; + @Unsigned int ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL = 0x3; + @Unsigned int ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL = 0x2; + @Unsigned int ME_COST_PENALTY_HIGH_INTEL = 0x3; + @Unsigned int ME_COST_PENALTY_LOW_INTEL = 0x1; + @Unsigned int ME_COST_PENALTY_NONE_INTEL = 0x0; + @Unsigned int ME_COST_PENALTY_NORMAL_INTEL = 0x2; + @Unsigned int ME_COST_PRECISION_DPEL_INTEL = 0x3; + @Unsigned int ME_COST_PRECISION_HPEL_INTEL = 0x1; + @Unsigned int ME_COST_PRECISION_PEL_INTEL = 0x2; + @Unsigned int ME_COST_PRECISION_QPEL_INTEL = 0x0; + @Unsigned int ME_FORWARD_INPUT_MODE_INTEL = 0x1; + @Unsigned int ME_LUMA_INTRA_PREDICT_ENABLED_INTEL = 0x2; + @Unsigned int ME_LUMA_PREDICTOR_MODE_DC_INTEL = 0x2; + @Unsigned int ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL = 0x3; + @Unsigned int ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL = 0x4; + @Unsigned int ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL = 0x6; + @Unsigned int ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL = 0x1; + @Unsigned int ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL = 0x8; + @Unsigned int ME_LUMA_PREDICTOR_MODE_PLANE_INTEL = 0x4; + @Unsigned int ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL = 0x0; + @Unsigned int ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL = 0x7; + @Unsigned int ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL = 0x5; + @Unsigned int ME_MB_TYPE_16x16_INTEL = 0x0; + @Unsigned int ME_MB_TYPE_4x4_INTEL = 0x2; + @Unsigned int ME_MB_TYPE_8x8_INTEL = 0x1; + @Unsigned int ME_SAD_ADJUST_MODE_HAAR_INTEL = 0x1; + @Unsigned int ME_SAD_ADJUST_MODE_NONE_INTEL = 0x0; + @Unsigned int ME_SEARCH_PATH_RADIUS_16_12_INTEL = 0x5; + @Unsigned int ME_SEARCH_PATH_RADIUS_2_2_INTEL = 0x0; + @Unsigned int ME_SEARCH_PATH_RADIUS_4_4_INTEL = 0x1; + @Unsigned int ME_SKIP_BLOCK_TYPE_16x16_INTEL = 0x0; + @Unsigned int ME_SKIP_BLOCK_TYPE_8x8_INTEL = 0x4; + @Unsigned int ME_SUBPIXEL_MODE_HPEL_INTEL = 0x1; + @Unsigned int ME_SUBPIXEL_MODE_INTEGER_INTEL = 0x0; + @Unsigned int ME_SUBPIXEL_MODE_QPEL_INTEL = 0x2; + @Unsigned int ME_VERSION_ADVANCED_VER_1_INTEL = 0x1; + @Unsigned int ME_VERSION_ADVANCED_VER_2_INTEL = 0x2; + @Unsigned int ME_VERSION_LEGACY_INTEL = 0x0; + @Unsigned int MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED = 0x2; + @Unsigned int MIGRATE_MEM_OBJECT_HOST = 0x1; + @Unsigned int MIGRATE_MEM_OBJECT_HOST_EXT = 0x1; + @Unsigned int MIPMAP_FILTER_ANY_IMG = 0x0; + @Unsigned int MIPMAP_FILTER_BOX_IMG = 0x1; + @Unsigned int MUTABLE_COMMAND_COMMAND_BUFFER_KHR = 0x12A1; + @Unsigned int MUTABLE_COMMAND_COMMAND_QUEUE_KHR = 0x12A0; + @Unsigned int MUTABLE_COMMAND_COMMAND_TYPE_KHR = 0x12AD; + @Unsigned int MUTABLE_COMMAND_PROPERTIES_ARRAY_KHR = 0x12A2; + @Unsigned int MUTABLE_DISPATCH_ARGUMENTS_KHR = 0x8; + @Unsigned int MUTABLE_DISPATCH_ASSERTS_KHR = 0x12B8; + @Unsigned int MUTABLE_DISPATCH_ASSERT_NO_ADDITIONAL_WORK_GROUPS_KHR = 0x1; + @Unsigned int MUTABLE_DISPATCH_DIMENSIONS_KHR = 0x12A4; + @Unsigned int MUTABLE_DISPATCH_EXEC_INFO_KHR = 0x10; + @Unsigned int MUTABLE_DISPATCH_GLOBAL_OFFSET_KHR = 0x1; + @Unsigned int MUTABLE_DISPATCH_GLOBAL_SIZE_KHR = 0x2; + @Unsigned int MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR = 0x12A5; + @Unsigned int MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR = 0x12A6; + @Unsigned int MUTABLE_DISPATCH_KERNEL_KHR = 0x12A3; + @Unsigned int MUTABLE_DISPATCH_LOCAL_SIZE_KHR = 0x4; + @Unsigned int MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR = 0x12A7; + @Unsigned int MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR = 0x12B1; + @Unsigned int NAME_VERSION_MAX_NAME_SIZE = 64; + @Unsigned int NAME_VERSION_MAX_NAME_SIZE_KHR = 64; + @Unsigned int NONE = 0x0; + @Unsigned int NV12_INTEL = 0x410E; + @Unsigned int NV21 = 0x40D0; + @Unsigned int NV21_IMG = 0x40D0; + @Unsigned long PARTITION_BY_COUNTS_LIST_END_EXT = 0; + @Unsigned int PERF_HINT_HIGH_QCOM = 0x40C3; + @Unsigned int PERF_HINT_LOW_QCOM = 0x40C5; + @Unsigned int PERF_HINT_NORMAL_QCOM = 0x40C4; + @Unsigned int PIPE_MAX_PACKETS = 0x1121; + @Unsigned int PIPE_PACKET_SIZE = 0x1120; + @Unsigned int PIPE_PROPERTIES = 0x1122; + @Unsigned int PLATFORM_COMMAND_BUFFER_CAPABILITIES_KHR = 0x0908; + @Unsigned int PLATFORM_EXTENSIONS = 0x0904; + @Unsigned int PLATFORM_EXTENSIONS_WITH_VERSION = 0x0907; + @Unsigned int PLATFORM_EXTENSIONS_WITH_VERSION_KHR = 0x0907; + @Unsigned int PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR = 0x2044; + @Unsigned int PLATFORM_HOST_TIMER_RESOLUTION = 0x0905; + @Unsigned int PLATFORM_ICD_SUFFIX_KHR = 0x0920; + @Unsigned int PLATFORM_NAME = 0x0902; + @Unsigned int PLATFORM_NUMERIC_VERSION = 0x0906; + @Unsigned int PLATFORM_NUMERIC_VERSION_KHR = 0x0906; + @Unsigned int PLATFORM_PROFILE = 0x0900; + @Unsigned int PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR = 0x2038; + @Unsigned int PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR = 0x2037; + @Unsigned int PLATFORM_SEMAPHORE_TYPES_KHR = 0x2036; + @Unsigned int PLATFORM_VENDOR = 0x0903; + @Unsigned int PLATFORM_VERSION = 0x0901; + @Unsigned int PREFERRED_DEVICES_FOR_D3D10_KHR = 0x4012; + @Unsigned int PREFERRED_DEVICES_FOR_D3D11_KHR = 0x401B; + @Unsigned int PREFERRED_DEVICES_FOR_DX9_INTEL = 0x4024; + @Unsigned int PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR = 0x2023; + @Unsigned int PREFERRED_DEVICES_FOR_VA_API_INTEL = 0x4095; + @Unsigned int PRINTF_BUFFERSIZE_ARM = 0x40B1; + @Unsigned int PRINTF_CALLBACK_ARM = 0x40B0; + @Unsigned int PROFILING_COMMAND_COMPLETE = 0x1284; + @Unsigned int PROFILING_COMMAND_END = 0x1283; + @Unsigned int PROFILING_COMMAND_QUEUED = 0x1280; + @Unsigned int PROFILING_COMMAND_START = 0x1282; + @Unsigned int PROFILING_COMMAND_SUBMIT = 0x1281; + @Unsigned int PROGRAM_BINARIES = 0x1166; + @Unsigned int PROGRAM_BINARY_SIZES = 0x1165; + @Unsigned int PROGRAM_BINARY_TYPE = 0x1184; + @Unsigned int PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1; + @Unsigned int PROGRAM_BINARY_TYPE_EXECUTABLE = 0x4; + @Unsigned int PROGRAM_BINARY_TYPE_INTERMEDIATE = 0x40E1; + @Unsigned int PROGRAM_BINARY_TYPE_LIBRARY = 0x2; + @Unsigned int PROGRAM_BINARY_TYPE_NONE = 0x0; + @Unsigned int PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE = 0x1185; + @Unsigned int PROGRAM_BUILD_LOG = 0x1183; + @Unsigned int PROGRAM_BUILD_OPTIONS = 0x1182; + @Unsigned int PROGRAM_BUILD_STATUS = 0x1181; + @Unsigned int PROGRAM_CONTEXT = 0x1161; + @Unsigned int PROGRAM_DEVICES = 0x1163; + @Unsigned int PROGRAM_HOST_PIPE_NAMES_INTEL = 0x4217; + @Unsigned int PROGRAM_IL = 0x1169; + @Unsigned int PROGRAM_IL_KHR = 0x1169; + @Unsigned int PROGRAM_KERNEL_NAMES = 0x1168; + @Unsigned int PROGRAM_NUM_DEVICES = 0x1162; + @Unsigned int PROGRAM_NUM_HOST_PIPES_INTEL = 0x4216; + @Unsigned int PROGRAM_NUM_KERNELS = 0x1167; + @Unsigned int PROGRAM_REFERENCE_COUNT = 0x1160; + @Unsigned int PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT = 0x116A; + @Unsigned int PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT = 0x116B; + @Unsigned int PROGRAM_SOURCE = 0x1164; + @Unsigned long PROPERTIES_LIST_END_EXT = 0; + @Unsigned int QUEUED = 0x3; + @Unsigned int QUEUE_CAPABILITY_BARRIER_INTEL = 0x2000000; + @Unsigned int QUEUE_CAPABILITY_CREATE_CROSS_QUEUE_EVENTS_INTEL = 0x2; + @Unsigned int QUEUE_CAPABILITY_CREATE_SINGLE_QUEUE_EVENTS_INTEL = 0x1; + @Unsigned int QUEUE_CAPABILITY_CROSS_QUEUE_EVENT_WAIT_LIST_INTEL = 0x8; + @Unsigned int QUEUE_CAPABILITY_FILL_BUFFER_INTEL = 0x800; + @Unsigned int QUEUE_CAPABILITY_FILL_IMAGE_INTEL = 0x4000; + @Unsigned int QUEUE_CAPABILITY_KERNEL_INTEL = 0x4000000; + @Unsigned int QUEUE_CAPABILITY_MAP_BUFFER_INTEL = 0x400; + @Unsigned int QUEUE_CAPABILITY_MAP_IMAGE_INTEL = 0x2000; + @Unsigned int QUEUE_CAPABILITY_MARKER_INTEL = 0x1000000; + @Unsigned int QUEUE_CAPABILITY_SINGLE_QUEUE_EVENT_WAIT_LIST_INTEL = 0x4; + @Unsigned int QUEUE_CAPABILITY_TRANSFER_BUFFER_IMAGE_INTEL = 0x8000; + @Unsigned int QUEUE_CAPABILITY_TRANSFER_BUFFER_INTEL = 0x100; + @Unsigned int QUEUE_CAPABILITY_TRANSFER_BUFFER_RECT_INTEL = 0x200; + @Unsigned int QUEUE_CAPABILITY_TRANSFER_IMAGE_BUFFER_INTEL = 0x10000; + @Unsigned int QUEUE_CAPABILITY_TRANSFER_IMAGE_INTEL = 0x1000; + @Unsigned int QUEUE_COMPUTE_UNIT_LIMIT_ARM = 0x41F3; + @Unsigned int QUEUE_CONTEXT = 0x1090; + @Unsigned int QUEUE_DEFAULT_CAPABILITIES_INTEL = 0; + @Unsigned int QUEUE_DEFERRED_FLUSH_ARM = 0x41EC; + @Unsigned int QUEUE_DEVICE = 0x1091; + @Unsigned int QUEUE_DEVICE_DEFAULT = 0x1095; + @Unsigned int QUEUE_FAMILY_INTEL = 0x418C; + @Unsigned int QUEUE_FAMILY_MAX_NAME_SIZE_INTEL = 64; + @Unsigned int QUEUE_INDEX_INTEL = 0x418D; + @Unsigned int QUEUE_JOB_SLOT_ARM = 0x41E1; + @Unsigned int QUEUE_KERNEL_BATCHING_ARM = 0x41E7; + @Unsigned int QUEUE_NO_SYNC_OPERATIONS_INTEL = 0x20000000; + @Unsigned int QUEUE_ON_DEVICE = 0x4; + @Unsigned int QUEUE_ON_DEVICE_DEFAULT = 0x8; + @Unsigned int QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = 0x1; + @Unsigned int QUEUE_PRIORITY_HIGH_KHR = 0x1; + @Unsigned int QUEUE_PRIORITY_KHR = 0x1096; + @Unsigned int QUEUE_PRIORITY_LOW_KHR = 0x4; + @Unsigned int QUEUE_PRIORITY_MED_KHR = 0x2; + @Unsigned int QUEUE_PROFILING_ENABLE = 0x2; + @Unsigned int QUEUE_PROPERTIES = 0x1093; + @Unsigned int QUEUE_PROPERTIES_ARRAY = 0x1098; + @Unsigned int QUEUE_REFERENCE_COUNT = 0x1092; + @Unsigned int QUEUE_RESERVED_QCOM = 0x40000000; + @Unsigned int QUEUE_SIZE = 0x1094; + @Unsigned int QUEUE_THREAD_LOCAL_EXEC_ENABLE_INTEL = 0x80000000; + @Unsigned int QUEUE_THROTTLE_HIGH_KHR = 0x1; + @Unsigned int QUEUE_THROTTLE_KHR = 0x1097; + @Unsigned int QUEUE_THROTTLE_LOW_KHR = 0x4; + @Unsigned int QUEUE_THROTTLE_MED_KHR = 0x2; + @Unsigned int R = 0x10B0; + @Unsigned int RA = 0x10B3; + @Unsigned int READ_ONLY_CACHE = 0x1; + @Unsigned int READ_WRITE_CACHE = 0x2; + @Unsigned int RESERVED0_IMG = 0x40D9; + @Unsigned int RESERVED1_IMG = 0x40DA; + @Unsigned int RESERVED2_IMG = 0x40DB; + @Unsigned int RG = 0x10B2; + @Unsigned int RGB = 0x10B4; + @Unsigned int RGBA = 0x10B5; + @Unsigned int RGBx = 0x10BC; + @Unsigned int RGx = 0x10BB; + @Unsigned int RUNNING = 0x1; + @Unsigned int Rx = 0x10BA; + @Unsigned int SAMPLER_ADDRESSING_MODE = 0x1153; + @Unsigned int SAMPLER_CONTEXT = 0x1151; + @Unsigned int SAMPLER_FILTER_MODE = 0x1154; + @Unsigned int SAMPLER_LOD_MAX = 0x1157; + @Unsigned int SAMPLER_LOD_MAX_KHR = 0x1157; + @Unsigned int SAMPLER_LOD_MIN = 0x1156; + @Unsigned int SAMPLER_LOD_MIN_KHR = 0x1156; + @Unsigned int SAMPLER_MIP_FILTER_MODE = 0x1155; + @Unsigned int SAMPLER_MIP_FILTER_MODE_KHR = 0x1155; + @Unsigned int SAMPLER_NORMALIZED_COORDS = 0x1152; + @Unsigned int SAMPLER_PROPERTIES = 0x1158; + @Unsigned int SAMPLER_REFERENCE_COUNT = 0x1150; + @Unsigned int SEMAPHORE_CONTEXT_KHR = 0x2039; + @Unsigned int SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR = 0; + @Unsigned int SEMAPHORE_DEVICE_HANDLE_LIST_KHR = 0x2053; + @Unsigned int SEMAPHORE_EXPORTABLE_KHR = 0x2054; + @Unsigned int SEMAPHORE_EXPORT_HANDLE_TYPES_KHR = 0x203F; + @Unsigned int SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR = 0; + @Unsigned int SEMAPHORE_HANDLE_D3D12_FENCE_KHR = 0x2059; + @Unsigned int SEMAPHORE_HANDLE_OPAQUE_FD_KHR = 0x2055; + @Unsigned int SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR = 0x2056; + @Unsigned int SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR = 0x2057; + @Unsigned int SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR = 0x2068; + @Unsigned int SEMAPHORE_HANDLE_SYNC_FD_KHR = 0x2058; + @Unsigned int SEMAPHORE_PAYLOAD_KHR = 0x203C; + @Unsigned int SEMAPHORE_PROPERTIES_KHR = 0x203B; + @Unsigned int SEMAPHORE_REFERENCE_COUNT_KHR = 0x203A; + @Unsigned int SEMAPHORE_TYPE_BINARY_KHR = 1; + @Unsigned int SEMAPHORE_TYPE_KHR = 0x203D; + @Unsigned int SHRT_MAX = 32767; + @Unsigned int SIGNED_INT16 = 0x10D8; + @Unsigned int SIGNED_INT32 = 0x10D9; + @Unsigned int SIGNED_INT8 = 0x10D7; + @Unsigned int SNORM_INT16 = 0x10D1; + @Unsigned int SNORM_INT8 = 0x10D0; + @Unsigned int STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR = 0; + @Unsigned int SUBMITTED = 0x2; + @Unsigned int SUCCESS = 0; + @Unsigned int TRUE = 1; + @Unsigned int UCHAR_MAX = 255; + @Unsigned int UINT_MAX = 0xffffffff; + @Unsigned int UNIFIED_SHARED_MEMORY_ACCESS_INTEL = 0x1; + @Unsigned int UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL = 0x2; + @Unsigned int UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS_INTEL = 0x4; + @Unsigned int UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS_INTEL = 0x8; + @Unsigned int UNORM_INT10X6_EXT = 0x10E1; + @Unsigned int UNORM_INT12X4_EXT = 0x10E9; + @Unsigned int UNORM_INT14X2_EXT = 0x10EA; + @Unsigned int UNORM_INT16 = 0x10D3; + @Unsigned int UNORM_INT24 = 0x10DF; + @Unsigned int UNORM_INT8 = 0x10D2; + @Unsigned int UNORM_INT_101010 = 0x10D6; + @Unsigned int UNORM_INT_101010_2 = 0x10E0; + @Unsigned int UNORM_INT_2_101010_EXT = 0x10E5; + @Unsigned int UNORM_SHORT_555 = 0x10D5; + @Unsigned int UNORM_SHORT_565 = 0x10D4; + @Unsigned int UNSIGNED_INT10X6_EXT = 0x10E6; + @Unsigned int UNSIGNED_INT12X4_EXT = 0x10E7; + @Unsigned int UNSIGNED_INT14X2_EXT = 0x10E8; + @Unsigned int UNSIGNED_INT16 = 0x10DB; + @Unsigned int UNSIGNED_INT32 = 0x10DC; + @Unsigned int UNSIGNED_INT8 = 0x10DA; + @Unsigned int UNSIGNED_INT_RAW10_EXT = 0x10E3; + @Unsigned int UNSIGNED_INT_RAW12_EXT = 0x10E4; + @Unsigned int USHRT_MAX = 65535; + @Unsigned int UUID_SIZE_KHR = 16; + @Unsigned int UYVY_INTEL = 0x4077; + @Unsigned int VA_API_DISPLAY_INTEL = 0x4094; + @Unsigned int VERSION_MAJOR_BITS = 10; + @Unsigned int VERSION_MAJOR_BITS_KHR = 10; + @Unsigned int VERSION_MINOR_BITS = 10; + @Unsigned int VERSION_MINOR_BITS_KHR = 10; + @Unsigned int VERSION_PATCH_BITS = 12; + @Unsigned int VERSION_PATCH_BITS_KHR = 12; + @Unsigned int VYUY_INTEL = 0x4079; + @Unsigned int WGL_HDC_KHR = 0x200B; + @Unsigned int YUYV_INTEL = 0x4076; + @Unsigned int YV12 = 0x40D1; + @Unsigned int YV12_IMG = 0x40D1; + @Unsigned int YVYU_INTEL = 0x4078; + @Unsigned int sBGRA = 0x10C2; + @Unsigned int sRGB = 0x10BF; + @Unsigned int sRGBA = 0x10C1; + @Unsigned int sRGBx = 0x10C0; + int ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL = -1097; + @Unsigned int AVC_ME_SKIP_BLOCK_16x16_BACKWARD_ENABLE_INTEL = (0x2 << 24); + @Unsigned int AVC_ME_SKIP_BLOCK_16x16_DUAL_ENABLE_INTEL = (0x3 << 24); + @Unsigned int AVC_ME_SKIP_BLOCK_16x16_FORWARD_ENABLE_INTEL = (0x1 << 24); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_0_BACKWARD_ENABLE_INTEL = (0x2 << 24); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_0_FORWARD_ENABLE_INTEL = (0x1 << 24); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_1_BACKWARD_ENABLE_INTEL = (0x2 << 26); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_1_FORWARD_ENABLE_INTEL = (0x1 << 26); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_2_BACKWARD_ENABLE_INTEL = (0x2 << 28); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_2_FORWARD_ENABLE_INTEL = (0x1 << 28); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_3_BACKWARD_ENABLE_INTEL = (0x2 << 30); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_3_FORWARD_ENABLE_INTEL = (0x1 << 30); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_BACKWARD_ENABLE_INTEL = (0xAA << 24); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_DUAL_ENABLE_INTEL = (0xFF << 24); + @Unsigned int AVC_ME_SKIP_BLOCK_8x8_FORWARD_ENABLE_INTEL = (0x55 << 24); + @Unsigned int BLOCKING = TRUE; + int BUILD_ERROR = -2; + int BUILD_IN_PROGRESS = -3; + int BUILD_NONE = -1; + int BUILD_PROGRAM_FAILURE = -11; + int CANCELLED_IMG = -1126; + byte CHAR_MAX = Byte.MAX_VALUE; + byte CHAR_MIN = Byte.MIN_VALUE; + int COMMAND_TERMINATED_ITSELF_WITH_FAILURE_ARM = -1108; + int COMPILER_NOT_AVAILABLE = -3; + int COMPILE_PROGRAM_FAILURE = -15; + int CONTEXT_TERMINATED_KHR = -1121; + int D3D10_RESOURCE_ALREADY_ACQUIRED_KHR = -1004; + int D3D10_RESOURCE_NOT_ACQUIRED_KHR = -1005; + int D3D11_RESOURCE_ALREADY_ACQUIRED_KHR = -1008; + int D3D11_RESOURCE_NOT_ACQUIRED_KHR = -1009; + double DBL_EPSILON = 2.220446049250313080847e-16; + double DBL_MAX = 1.7976931348623158e+308; + int DBL_MAX_10_EXP = +308; + int DBL_MAX_EXP = +1024; + double DBL_MIN = 2.225073858507201383090e-308; + int DBL_MIN_10_EXP = -307; + int DBL_MIN_EXP = -1021; + int DEVICE_NOT_AVAILABLE = -2; + int DEVICE_NOT_FOUND = -1; + int DEVICE_PARTITION_FAILED = -18; + int DEVICE_PARTITION_FAILED_EXT = -1057; + @Unsigned long DEVICE_TYPE_RESERVED0_QCOM = 0x100000000L; + int DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR = -1012; + int DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR = -1013; + int DX9_RESOURCE_ALREADY_ACQUIRED_INTEL = -1012; + int DX9_RESOURCE_NOT_ACQUIRED_INTEL = -1013; + int EGL_RESOURCE_NOT_ACQUIRED_KHR = -1092; + int ERROR_RESERVED0_IMG = -1122; + int ERROR_RESERVED1_IMG = -1123; + int ERROR_RESERVED2_IMG = -1124; + int ERROR_RESERVED3_IMG = -1125; + int EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST = -14; + float FLT_EPSILON = 1.1920928955078125e-7f; + float FLT_MAX = 340282346638528859811704183484516925440.0f; + int FLT_MAX_10_EXP = +38; + int FLT_MAX_EXP = +128; + float FLT_MIN = 1.175494350822287507969e-38f; + int FLT_MIN_10_EXP = -37; + int FLT_MIN_EXP = -125; + float HALF_EPSILON = 9.765625e-04f; + float HALF_MAX = 65504.0f; + int HALF_MAX_10_EXP = +4; + int HALF_MAX_EXP = +16; + float HALF_MIN = 6.103515625e-05f; + int HALF_MIN_10_EXP = -4; + int HALF_MIN_EXP = -13; + double HUGE_VAL = Double.POSITIVE_INFINITY; + float HUGE_VALF = Float.POSITIVE_INFINITY; + int IMAGE_FORMAT_MISMATCH = -9; + int IMAGE_FORMAT_NOT_SUPPORTED = -10; + long IMPORT_MEMORY_WHOLE_ALLOCATION_ARM = 0xFFFFFFFF_FFFFFFFFL; + int INCOMPATIBLE_COMMAND_QUEUE_KHR = -1140; + float INFINITY = Float.POSITIVE_INFINITY; + @Unsigned int INT_MIN = (-2147483647-1); + int INVALID_ACCELERATOR_DESCRIPTOR_INTEL = -1096; + int INVALID_ACCELERATOR_INTEL = -1094; + int INVALID_ACCELERATOR_TYPE_INTEL = -1095; + int INVALID_ARG_INDEX = -49; + int INVALID_ARG_SIZE = -51; + int INVALID_ARG_VALUE = -50; + int INVALID_BINARY = -42; + int INVALID_BUFFER_SIZE = -61; + int INVALID_BUILD_OPTIONS = -43; + int INVALID_COMMAND_BUFFER_KHR = -1138; + int INVALID_COMMAND_QUEUE = -36; + int INVALID_COMPILER_OPTIONS = -66; + int INVALID_CONTEXT = -34; + int INVALID_D3D10_DEVICE_KHR = -1002; + int INVALID_D3D10_RESOURCE_KHR = -1003; + int INVALID_D3D11_DEVICE_KHR = -1006; + int INVALID_D3D11_RESOURCE_KHR = -1007; + int INVALID_DEVICE = -33; + int INVALID_DEVICE_PARTITION_COUNT = -68; + int INVALID_DEVICE_QUEUE = -70; + int INVALID_DEVICE_TYPE = -31; + int INVALID_DX9_DEVICE_INTEL = -1010; + int INVALID_DX9_MEDIA_ADAPTER_KHR = -1010; + int INVALID_DX9_MEDIA_SURFACE_KHR = -1011; + int INVALID_DX9_RESOURCE_INTEL = -1011; + int INVALID_EGL_OBJECT_KHR = -1093; + int INVALID_EVENT = -58; + int INVALID_EVENT_WAIT_LIST = -57; + int INVALID_GLOBAL_OFFSET = -56; + int INVALID_GLOBAL_WORK_SIZE = -63; + int INVALID_GL_OBJECT = -60; + int INVALID_GL_SHAREGROUP_REFERENCE_KHR = -1000; + int INVALID_HOST_PTR = -37; + int INVALID_IMAGE_DESCRIPTOR = -65; + int INVALID_IMAGE_FORMAT_DESCRIPTOR = -39; + int INVALID_IMAGE_SIZE = -40; + int INVALID_KERNEL = -48; + int INVALID_KERNEL_ARGS = -52; + int INVALID_KERNEL_DEFINITION = -47; + int INVALID_KERNEL_NAME = -46; + int INVALID_LINKER_OPTIONS = -67; + int INVALID_MEM_OBJECT = -38; + int INVALID_MIP_LEVEL = -62; + int INVALID_MUTABLE_COMMAND_KHR = -1141; + int INVALID_OPERATION = -59; + int INVALID_PARTITION_COUNT_EXT = -1058; + int INVALID_PARTITION_NAME_EXT = -1059; + int INVALID_PIPE_SIZE = -69; + int INVALID_PLATFORM = -32; + int INVALID_PROGRAM = -44; + int INVALID_PROGRAM_EXECUTABLE = -45; + int INVALID_PROPERTY = -64; + int INVALID_QUEUE_PROPERTIES = -35; + int INVALID_SAMPLER = -41; + int INVALID_SEMAPHORE_KHR = -1142; + int INVALID_SPEC_ID = -71; + int INVALID_SYNC_POINT_WAIT_LIST_KHR = -1139; + int INVALID_VALUE = -30; + int INVALID_VA_API_MEDIA_ADAPTER_INTEL = -1098; + int INVALID_VA_API_MEDIA_SURFACE_INTEL = -1099; + int INVALID_WORK_DIMENSION = -53; + int INVALID_WORK_GROUP_SIZE = -54; + int INVALID_WORK_ITEM_SIZE = -55; + int KERNEL_ARG_INFO_NOT_AVAILABLE = -19; + int LINKER_NOT_AVAILABLE = -16; + int LINK_PROGRAM_FAILURE = -17; + long LONG_MAX = Long.MAX_VALUE; + long LONG_MIN = Long.MIN_VALUE; + int MAP_FAILURE = -12; + float MAXFLOAT = FLT_MAX; + int MAX_SIZE_RESTRICTION_EXCEEDED = -72; + int MEM_COPY_OVERLAP = -8; + int MEM_OBJECT_ALLOCATION_FAILURE = -4; + @Unsigned long MEM_PROTECTED_ALLOC_ARM = 0x1000000000L; + @Unsigned long MEM_RESERVED0_ARM = 0x100000000L; + @Unsigned long MEM_RESERVED0_QCOM = 0x2000000000L; + @Unsigned long MEM_RESERVED1_ARM = 0x200000000L; + @Unsigned long MEM_RESERVED1_QCOM = 0x4000000000L; + @Unsigned long MEM_RESERVED2_ARM = 0x400000000L; + @Unsigned long MEM_RESERVED2_QCOM = 0x8000000000L; + @Unsigned long MEM_RESERVED3_ARM = 0x800000000L; + @Unsigned long MEM_RESERVED3_QCOM = 0x10000000000L; + int MISALIGNED_SUB_BUFFER_OFFSET = -13; + double M_1_PI = 0.31830988618379067154; + float M_1_PI_F = 0.318309886f; + double M_2_PI = 0.63661977236758134308; + float M_2_PI_F = 0.636619772f; + double M_2_SQRTPI = 1.12837916709551257390; + float M_2_SQRTPI_F = 1.128379167f; + double M_E = 2.7182818284590452354; + float M_E_F = 2.718281828f; + double M_LN10 = 2.30258509299404568402; + float M_LN10_F = 2.302585093f; + double M_LN2 = 0.69314718055994530942; + float M_LN2_F = 0.693147181f; + double M_LOG10E = 0.43429448190325182765; + float M_LOG10E_F = 0.434294482f; + double M_LOG2E = 1.4426950408889634074; + float M_LOG2E_F = 1.442695041f; + double M_PI = 3.14159265358979323846; + double M_PI_2 = 1.57079632679489661923; + float M_PI_2_F = 1.570796327f; + double M_PI_4 = 0.78539816339744830962; + float M_PI_4_F = 0.785398163f; + float M_PI_F = 3.141592654f; + double M_SQRT1_2 = 0.70710678118654752440; + float M_SQRT1_2_F = 0.707106781f; + double M_SQRT2 = 1.41421356237309504880; + float M_SQRT2_F = 1.414213562f; + float NAN = Float.NaN; + @Unsigned int NON_BLOCKING = FALSE; + int OUT_OF_HOST_MEMORY = -6; + int OUT_OF_RESOURCES = -5; + @Unsigned long PARTITION_BY_NAMES_LIST_END_EXT = 0 - 1; + int PARTITION_BY_NAMES_LIST_END_INTEL = -1; + int PIPE_EMPTY_INTEL = -1107; + int PIPE_FULL_INTEL = -1106; + int PLATFORM_NOT_FOUND_KHR = -1001; + int PROFILING_INFO_NOT_AVAILABLE = -7; + byte SCHAR_MAX = Byte.MAX_VALUE; + byte SCHAR_MIN = Byte.MIN_VALUE; + @Unsigned int SHRT_MIN = (-32767-1); + @Unsigned long ULONG_MAX = 0xFFFFFFFF_FFFFFFFFL; + int VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL = -1100; + int VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL = -1101; +} diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_free_func_0.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_free_func_0.class new file mode 100644 index 0000000..3ae2f90 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_free_func_0.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_free_func_1.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_free_func_1.class new file mode 100644 index 0000000..e159f3e Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_free_func_1.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_0.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_0.class new file mode 100644 index 0000000..b736995 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_0.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_1.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_1.class new file mode 100644 index 0000000..914cfe6 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_1.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_2.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_2.class new file mode 100644 index 0000000..05ae9b5 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_2.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_3.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_3.class new file mode 100644 index 0000000..d9a10a3 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_3.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_4.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_4.class new file mode 100644 index 0000000..5fae46d Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_4.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_5.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_5.class new file mode 100644 index 0000000..ad89b8a Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_5.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_6.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_6.class new file mode 100644 index 0000000..e490a60 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_6.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_7.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_7.class new file mode 100644 index 0000000..3ca64b9 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_7.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_8.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_8.class new file mode 100644 index 0000000..4a00755 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_8.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_9.class b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_9.class new file mode 100644 index 0000000..90d7f65 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Ipfn_notify_9.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes$Iuser_func_0.class b/src/club/doki7/opencl/CLFunctionTypes$Iuser_func_0.class new file mode 100644 index 0000000..bd0a68f Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes$Iuser_func_0.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes.class b/src/club/doki7/opencl/CLFunctionTypes.class new file mode 100644 index 0000000..dfc1163 Binary files /dev/null and b/src/club/doki7/opencl/CLFunctionTypes.class differ diff --git a/src/club/doki7/opencl/CLFunctionTypes.java b/src/club/doki7/opencl/CLFunctionTypes.java new file mode 100644 index 0000000..577aa7c --- /dev/null +++ b/src/club/doki7/opencl/CLFunctionTypes.java @@ -0,0 +1,420 @@ +package club.doki7.opencl; + +import java.lang.foreign.*; +import java.lang.invoke.*; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.NativeLayout; +import org.jetbrains.annotations.NotNull; +import club.doki7.opencl.datatype.*; +import club.doki7.opencl.handle.*; + +public final class CLFunctionTypes { + public static final FunctionDescriptor pfn_free_func_0 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_free_func_1 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS), + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_0 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_1 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.JAVA_BYTE), + ValueLayout.ADDRESS, + NativeLayout.C_SIZE_T, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_2 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_3 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_4 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_5 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_6 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_7 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_8 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor pfn_notify_9 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS + ); + + public static final FunctionDescriptor user_func_0 = FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS + ); + + @FunctionalInterface + public interface Ipfn_free_func_0 { + void invoke( + @NativeType("CLCommandQueue") MemorySegment p0, + @NativeType("cl_uint") @Unsigned int p1, + @Pointer(comment="void*") @NotNull MemorySegment p2, + @Pointer(comment="void*") @NotNull MemorySegment p3 + ); + + static MethodHandle of(@NotNull Ipfn_free_func_0 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_free_func_0.class, "invoke", pfn_free_func_0.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_free_func_0 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_free_func_0 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_free_func_0, arena); + } + } + + @FunctionalInterface + public interface Ipfn_free_func_1 { + void invoke( + @NativeType("CLCommandQueue") MemorySegment p0, + @NativeType("cl_uint") @Unsigned int p1, + @Pointer(comment="void*") @NotNull MemorySegment p2, + @Pointer(comment="void*") @NotNull MemorySegment p3 + ); + + static MethodHandle of(@NotNull Ipfn_free_func_1 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_free_func_1.class, "invoke", pfn_free_func_1.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_free_func_1 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_free_func_1 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_free_func_1, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_0 { + void invoke( + @Pointer(comment="void*") @NotNull MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1, + @NativeType("size_t") MemorySegment p2, + @Pointer(comment="void*") @NotNull MemorySegment p3 + ); + + static MethodHandle of(@NotNull Ipfn_notify_0 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_0.class, "invoke", pfn_notify_0.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_0 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_0 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_0, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_1 { + void invoke( + @Pointer(comment="void*") @NotNull MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1, + @NativeType("size_t") MemorySegment p2, + @Pointer(comment="void*") @NotNull MemorySegment p3 + ); + + static MethodHandle of(@NotNull Ipfn_notify_1 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_1.class, "invoke", pfn_notify_1.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_1 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_1 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_1, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_2 { + void invoke( + @NativeType("CLContext") MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1 + ); + + static MethodHandle of(@NotNull Ipfn_notify_2 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_2.class, "invoke", pfn_notify_2.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_2 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_2 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_2, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_3 { + void invoke( + @NativeType("CLMem") MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1 + ); + + static MethodHandle of(@NotNull Ipfn_notify_3 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_3.class, "invoke", pfn_notify_3.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_3 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_3 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_3, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_4 { + void invoke( + @NativeType("CLMem") MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1 + ); + + static MethodHandle of(@NotNull Ipfn_notify_4 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_4.class, "invoke", pfn_notify_4.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_4 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_4 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_4, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_5 { + void invoke( + @NativeType("CLProgram") MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1 + ); + + static MethodHandle of(@NotNull Ipfn_notify_5 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_5.class, "invoke", pfn_notify_5.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_5 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_5 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_5, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_6 { + void invoke( + @NativeType("CLProgram") MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1 + ); + + static MethodHandle of(@NotNull Ipfn_notify_6 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_6.class, "invoke", pfn_notify_6.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_6 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_6 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_6, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_7 { + void invoke( + @NativeType("CLProgram") MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1 + ); + + static MethodHandle of(@NotNull Ipfn_notify_7 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_7.class, "invoke", pfn_notify_7.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_7 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_7 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_7, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_8 { + void invoke( + @NativeType("CLProgram") MemorySegment p0, + @Pointer(comment="void*") @NotNull MemorySegment p1 + ); + + static MethodHandle of(@NotNull Ipfn_notify_8 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_8.class, "invoke", pfn_notify_8.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_8 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_8 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_8, arena); + } + } + + @FunctionalInterface + public interface Ipfn_notify_9 { + void invoke( + @NativeType("CLEvent") MemorySegment p0, + @NativeType("cl_int") int p1, + @Pointer(comment="void*") @NotNull MemorySegment p2 + ); + + static MethodHandle of(@NotNull Ipfn_notify_9 lambda) { + try { + return MethodHandles.lookup().findVirtual(Ipfn_notify_9.class, "invoke", pfn_notify_9.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Ipfn_notify_9 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Ipfn_notify_9 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), pfn_notify_9, arena); + } + } + + @FunctionalInterface + public interface Iuser_func_0 { + void invoke( + @Pointer(comment="void*") @NotNull MemorySegment p0 + ); + + static MethodHandle of(@NotNull Iuser_func_0 lambda) { + try { + return MethodHandles.lookup().findVirtual(Iuser_func_0.class, "invoke", user_func_0.toMethodType()).bindTo(lambda); + } + catch (NoSuchMethodException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + static MemorySegment ofNative(@NotNull Iuser_func_0 lambda) { + return ofNative(Arena.global(), lambda); + } + + static MemorySegment ofNative(@NotNull Arena arena, @NotNull Iuser_func_0 lambda) { + return Linker.nativeLinker().upcallStub(of(lambda), user_func_0, arena); + } + } + + /// Constructing this class is nonsense so the constructor is made private. + private CLFunctionTypes() {} +} diff --git a/src/club/doki7/opencl/CLVersion.class b/src/club/doki7/opencl/CLVersion.class new file mode 100644 index 0000000..28ab7cf Binary files /dev/null and b/src/club/doki7/opencl/CLVersion.class differ diff --git a/src/club/doki7/opencl/CLVersion.java b/src/club/doki7/opencl/CLVersion.java new file mode 100644 index 0000000..7a625e7 --- /dev/null +++ b/src/club/doki7/opencl/CLVersion.java @@ -0,0 +1,29 @@ +package club.doki7.opencl; + +import org.jetbrains.annotations.NotNull; + +public record CLVersion(int major, int minor, int patch) { + public static final int VERSION_MAJOR_BITS = 10; + public static final int VERSION_MINOR_BITS = 10; + public static final int VERSION_PATCH_BITS = 12; + + public static final int VERSION_MAJOR_MASK = (1 << VERSION_MAJOR_BITS) - 1; + public static final int VERSION_MINOR_MASK = (1 << VERSION_MINOR_BITS) - 1; + public static final int VERSION_PATCH_MASK = (1 << VERSION_PATCH_BITS) - 1; + + public static @NotNull CLVersion decode(int version) { + var major = version >> (VERSION_MINOR_BITS + VERSION_PATCH_BITS); + var minor = (version >> VERSION_PATCH_BITS) & VERSION_MINOR_MASK; + var patch = version & VERSION_PATCH_MASK; + + return new CLVersion(major, minor, patch); + } + + public int encode() { + var preMajor = (major & VERSION_MAJOR_MASK) << (VERSION_MINOR_BITS + VERSION_PATCH_BITS); + var preMinor = (minor & VERSION_MINOR_MASK) << VERSION_PATCH_BITS; + var prePatch = patch & VERSION_PATCH_BITS; + + return preMajor | preMinor | prePatch; + } +} diff --git a/src/club/doki7/opencl/datatype/CLBufferRegion$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLBufferRegion$Ptr$Iter.class new file mode 100644 index 0000000..de835fc Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLBufferRegion$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLBufferRegion$Ptr.class b/src/club/doki7/opencl/datatype/CLBufferRegion$Ptr.class new file mode 100644 index 0000000..ed4436d Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLBufferRegion$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLBufferRegion.class b/src/club/doki7/opencl/datatype/CLBufferRegion.class new file mode 100644 index 0000000..886220e Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLBufferRegion.class differ diff --git a/src/club/doki7/opencl/datatype/CLBufferRegion.java b/src/club/doki7/opencl/datatype/CLBufferRegion.java new file mode 100644 index 0000000..e8f1ee0 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLBufferRegion.java @@ -0,0 +1,210 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_buffer_region structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_buffer_region { +/// size_t origin; // @link substring="origin" target="#origin" +/// size_t size; // @link substring="size" target="#size" +/// } cl_buffer_region; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_buffer_region +@ValueBasedCandidate +@UnsafeConstructor +public record CLBufferRegion(@NotNull MemorySegment segment) implements ICLBufferRegion { + /// Represents a pointer to / an array of cl_buffer_region structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLBufferRegion}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLBufferRegion to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLBufferRegion.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLBufferRegion, Iterable { + public long size() { + return segment.byteSize() / CLBufferRegion.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLBufferRegion at(long index) { + return new CLBufferRegion(segment.asSlice(index * CLBufferRegion.BYTES, CLBufferRegion.BYTES)); + } + + public CLBufferRegion.Ptr at(long index, @NotNull Consumer<@NotNull CLBufferRegion> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLBufferRegion value) { + MemorySegment s = segment.asSlice(index * CLBufferRegion.BYTES, CLBufferRegion.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLBufferRegion.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLBufferRegion.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLBufferRegion.BYTES, + (end - start) * CLBufferRegion.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLBufferRegion.BYTES)); + } + + public CLBufferRegion[] toArray() { + CLBufferRegion[] ret = new CLBufferRegion[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLBufferRegion.BYTES; + } + + @Override + public CLBufferRegion next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLBufferRegion ret = new CLBufferRegion(segment.asSlice(0, CLBufferRegion.BYTES)); + segment = segment.asSlice(CLBufferRegion.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLBufferRegion allocate(Arena arena) { + return new CLBufferRegion(arena.allocate(LAYOUT)); + } + + public static CLBufferRegion.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLBufferRegion.Ptr(segment); + } + + public static CLBufferRegion clone(Arena arena, CLBufferRegion src) { + CLBufferRegion ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @Unsigned long origin() { + return NativeLayout.readCSizeT(segment, OFFSET$origin); + } + + public CLBufferRegion origin(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$origin, value); + return this; + } + + public @Unsigned long size() { + return NativeLayout.readCSizeT(segment, OFFSET$size); + } + + public CLBufferRegion size(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$size, value); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + NativeLayout.C_SIZE_T.withName("origin"), + NativeLayout.C_SIZE_T.withName("size") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$origin = PathElement.groupElement("origin"); + public static final PathElement PATH$size = PathElement.groupElement("size"); + + + public static final long SIZE$origin = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$size = NativeLayout.C_SIZE_T.byteSize(); + + public static final long OFFSET$origin = LAYOUT.byteOffset(PATH$origin); + public static final long OFFSET$size = LAYOUT.byteOffset(PATH$size); +} diff --git a/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr$Ptr$Iter.class new file mode 100644 index 0000000..b371eff Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr$Ptr.class b/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr$Ptr.class new file mode 100644 index 0000000..929a304 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr.class b/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr.class new file mode 100644 index 0000000..f1536e5 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr.class differ diff --git a/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr.java b/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr.java new file mode 100644 index 0000000..7be54bf --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLDeviceIntegerDotProductAccelerationPropertiesKhr.java @@ -0,0 +1,272 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_device_integer_dot_product_acceleration_properties_khr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_device_integer_dot_product_acceleration_properties_khr { +/// cl_bool signedAccelerated; // @link substring="signedAccelerated" target="#signedAccelerated" +/// cl_bool unsignedAccelerated; // @link substring="unsignedAccelerated" target="#unsignedAccelerated" +/// cl_bool mixedSignednessAccelerated; // @link substring="mixedSignednessAccelerated" target="#mixedSignednessAccelerated" +/// cl_bool accumulatingSaturatingSignedAccelerated; // @link substring="accumulatingSaturatingSignedAccelerated" target="#accumulatingSaturatingSignedAccelerated" +/// cl_bool accumulatingSaturatingUnsignedAccelerated; // @link substring="accumulatingSaturatingUnsignedAccelerated" target="#accumulatingSaturatingUnsignedAccelerated" +/// cl_bool accumulatingSaturatingMixedSignednessAccelerated; // @link substring="accumulatingSaturatingMixedSignednessAccelerated" target="#accumulatingSaturatingMixedSignednessAccelerated" +/// } cl_device_integer_dot_product_acceleration_properties_khr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_device_integer_dot_product_acceleration_properties_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLDeviceIntegerDotProductAccelerationPropertiesKhr(@NotNull MemorySegment segment) implements ICLDeviceIntegerDotProductAccelerationPropertiesKhr { + /// Represents a pointer to / an array of cl_device_integer_dot_product_acceleration_properties_khr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLDeviceIntegerDotProductAccelerationPropertiesKhr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLDeviceIntegerDotProductAccelerationPropertiesKhr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLDeviceIntegerDotProductAccelerationPropertiesKhr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLDeviceIntegerDotProductAccelerationPropertiesKhr, Iterable { + public long size() { + return segment.byteSize() / CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLDeviceIntegerDotProductAccelerationPropertiesKhr at(long index) { + return new CLDeviceIntegerDotProductAccelerationPropertiesKhr(segment.asSlice(index * CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES, CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES)); + } + + public CLDeviceIntegerDotProductAccelerationPropertiesKhr.Ptr at(long index, @NotNull Consumer<@NotNull CLDeviceIntegerDotProductAccelerationPropertiesKhr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLDeviceIntegerDotProductAccelerationPropertiesKhr value) { + MemorySegment s = segment.asSlice(index * CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES, CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES, + (end - start) * CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES)); + } + + public CLDeviceIntegerDotProductAccelerationPropertiesKhr[] toArray() { + CLDeviceIntegerDotProductAccelerationPropertiesKhr[] ret = new CLDeviceIntegerDotProductAccelerationPropertiesKhr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES; + } + + @Override + public CLDeviceIntegerDotProductAccelerationPropertiesKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLDeviceIntegerDotProductAccelerationPropertiesKhr ret = new CLDeviceIntegerDotProductAccelerationPropertiesKhr(segment.asSlice(0, CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES)); + segment = segment.asSlice(CLDeviceIntegerDotProductAccelerationPropertiesKhr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLDeviceIntegerDotProductAccelerationPropertiesKhr allocate(Arena arena) { + return new CLDeviceIntegerDotProductAccelerationPropertiesKhr(arena.allocate(LAYOUT)); + } + + public static CLDeviceIntegerDotProductAccelerationPropertiesKhr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLDeviceIntegerDotProductAccelerationPropertiesKhr.Ptr(segment); + } + + public static CLDeviceIntegerDotProductAccelerationPropertiesKhr clone(Arena arena, CLDeviceIntegerDotProductAccelerationPropertiesKhr src) { + CLDeviceIntegerDotProductAccelerationPropertiesKhr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_bool") @Unsigned int signedAccelerated() { + return segment.get(LAYOUT$signedAccelerated, OFFSET$signedAccelerated); + } + + public CLDeviceIntegerDotProductAccelerationPropertiesKhr signedAccelerated(@NativeType("cl_bool") @Unsigned int value) { + segment.set(LAYOUT$signedAccelerated, OFFSET$signedAccelerated, value); + return this; + } + + public @NativeType("cl_bool") @Unsigned int unsignedAccelerated() { + return segment.get(LAYOUT$unsignedAccelerated, OFFSET$unsignedAccelerated); + } + + public CLDeviceIntegerDotProductAccelerationPropertiesKhr unsignedAccelerated(@NativeType("cl_bool") @Unsigned int value) { + segment.set(LAYOUT$unsignedAccelerated, OFFSET$unsignedAccelerated, value); + return this; + } + + public @NativeType("cl_bool") @Unsigned int mixedSignednessAccelerated() { + return segment.get(LAYOUT$mixedSignednessAccelerated, OFFSET$mixedSignednessAccelerated); + } + + public CLDeviceIntegerDotProductAccelerationPropertiesKhr mixedSignednessAccelerated(@NativeType("cl_bool") @Unsigned int value) { + segment.set(LAYOUT$mixedSignednessAccelerated, OFFSET$mixedSignednessAccelerated, value); + return this; + } + + public @NativeType("cl_bool") @Unsigned int accumulatingSaturatingSignedAccelerated() { + return segment.get(LAYOUT$accumulatingSaturatingSignedAccelerated, OFFSET$accumulatingSaturatingSignedAccelerated); + } + + public CLDeviceIntegerDotProductAccelerationPropertiesKhr accumulatingSaturatingSignedAccelerated(@NativeType("cl_bool") @Unsigned int value) { + segment.set(LAYOUT$accumulatingSaturatingSignedAccelerated, OFFSET$accumulatingSaturatingSignedAccelerated, value); + return this; + } + + public @NativeType("cl_bool") @Unsigned int accumulatingSaturatingUnsignedAccelerated() { + return segment.get(LAYOUT$accumulatingSaturatingUnsignedAccelerated, OFFSET$accumulatingSaturatingUnsignedAccelerated); + } + + public CLDeviceIntegerDotProductAccelerationPropertiesKhr accumulatingSaturatingUnsignedAccelerated(@NativeType("cl_bool") @Unsigned int value) { + segment.set(LAYOUT$accumulatingSaturatingUnsignedAccelerated, OFFSET$accumulatingSaturatingUnsignedAccelerated, value); + return this; + } + + public @NativeType("cl_bool") @Unsigned int accumulatingSaturatingMixedSignednessAccelerated() { + return segment.get(LAYOUT$accumulatingSaturatingMixedSignednessAccelerated, OFFSET$accumulatingSaturatingMixedSignednessAccelerated); + } + + public CLDeviceIntegerDotProductAccelerationPropertiesKhr accumulatingSaturatingMixedSignednessAccelerated(@NativeType("cl_bool") @Unsigned int value) { + segment.set(LAYOUT$accumulatingSaturatingMixedSignednessAccelerated, OFFSET$accumulatingSaturatingMixedSignednessAccelerated, value); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("signedAccelerated"), + ValueLayout.JAVA_INT.withName("unsignedAccelerated"), + ValueLayout.JAVA_INT.withName("mixedSignednessAccelerated"), + ValueLayout.JAVA_INT.withName("accumulatingSaturatingSignedAccelerated"), + ValueLayout.JAVA_INT.withName("accumulatingSaturatingUnsignedAccelerated"), + ValueLayout.JAVA_INT.withName("accumulatingSaturatingMixedSignednessAccelerated") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$signedAccelerated = PathElement.groupElement("signedAccelerated"); + public static final PathElement PATH$unsignedAccelerated = PathElement.groupElement("unsignedAccelerated"); + public static final PathElement PATH$mixedSignednessAccelerated = PathElement.groupElement("mixedSignednessAccelerated"); + public static final PathElement PATH$accumulatingSaturatingSignedAccelerated = PathElement.groupElement("accumulatingSaturatingSignedAccelerated"); + public static final PathElement PATH$accumulatingSaturatingUnsignedAccelerated = PathElement.groupElement("accumulatingSaturatingUnsignedAccelerated"); + public static final PathElement PATH$accumulatingSaturatingMixedSignednessAccelerated = PathElement.groupElement("accumulatingSaturatingMixedSignednessAccelerated"); + + public static final OfInt LAYOUT$signedAccelerated = (OfInt) LAYOUT.select(PATH$signedAccelerated); + public static final OfInt LAYOUT$unsignedAccelerated = (OfInt) LAYOUT.select(PATH$unsignedAccelerated); + public static final OfInt LAYOUT$mixedSignednessAccelerated = (OfInt) LAYOUT.select(PATH$mixedSignednessAccelerated); + public static final OfInt LAYOUT$accumulatingSaturatingSignedAccelerated = (OfInt) LAYOUT.select(PATH$accumulatingSaturatingSignedAccelerated); + public static final OfInt LAYOUT$accumulatingSaturatingUnsignedAccelerated = (OfInt) LAYOUT.select(PATH$accumulatingSaturatingUnsignedAccelerated); + public static final OfInt LAYOUT$accumulatingSaturatingMixedSignednessAccelerated = (OfInt) LAYOUT.select(PATH$accumulatingSaturatingMixedSignednessAccelerated); + + public static final long SIZE$signedAccelerated = LAYOUT$signedAccelerated.byteSize(); + public static final long SIZE$unsignedAccelerated = LAYOUT$unsignedAccelerated.byteSize(); + public static final long SIZE$mixedSignednessAccelerated = LAYOUT$mixedSignednessAccelerated.byteSize(); + public static final long SIZE$accumulatingSaturatingSignedAccelerated = LAYOUT$accumulatingSaturatingSignedAccelerated.byteSize(); + public static final long SIZE$accumulatingSaturatingUnsignedAccelerated = LAYOUT$accumulatingSaturatingUnsignedAccelerated.byteSize(); + public static final long SIZE$accumulatingSaturatingMixedSignednessAccelerated = LAYOUT$accumulatingSaturatingMixedSignednessAccelerated.byteSize(); + + public static final long OFFSET$signedAccelerated = LAYOUT.byteOffset(PATH$signedAccelerated); + public static final long OFFSET$unsignedAccelerated = LAYOUT.byteOffset(PATH$unsignedAccelerated); + public static final long OFFSET$mixedSignednessAccelerated = LAYOUT.byteOffset(PATH$mixedSignednessAccelerated); + public static final long OFFSET$accumulatingSaturatingSignedAccelerated = LAYOUT.byteOffset(PATH$accumulatingSaturatingSignedAccelerated); + public static final long OFFSET$accumulatingSaturatingUnsignedAccelerated = LAYOUT.byteOffset(PATH$accumulatingSaturatingUnsignedAccelerated); + public static final long OFFSET$accumulatingSaturatingMixedSignednessAccelerated = LAYOUT.byteOffset(PATH$accumulatingSaturatingMixedSignednessAccelerated); +} diff --git a/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr$Ptr$Iter.class new file mode 100644 index 0000000..280bb75 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr$Ptr.class b/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr$Ptr.class new file mode 100644 index 0000000..ab9a819 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr.class b/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr.class new file mode 100644 index 0000000..dd549e8 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr.class differ diff --git a/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr.java b/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr.java new file mode 100644 index 0000000..aaa099c --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLDevicePciBusInfoKhr.java @@ -0,0 +1,242 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_device_pci_bus_info_khr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_device_pci_bus_info_khr { +/// cl_uint pciDomain; // @link substring="pciDomain" target="#pciDomain" +/// cl_uint pciBus; // @link substring="pciBus" target="#pciBus" +/// cl_uint pciDevice; // @link substring="pciDevice" target="#pciDevice" +/// cl_uint pciFunction; // @link substring="pciFunction" target="#pciFunction" +/// } cl_device_pci_bus_info_khr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_device_pci_bus_info_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLDevicePciBusInfoKhr(@NotNull MemorySegment segment) implements ICLDevicePciBusInfoKhr { + /// Represents a pointer to / an array of cl_device_pci_bus_info_khr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLDevicePciBusInfoKhr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLDevicePciBusInfoKhr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLDevicePciBusInfoKhr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLDevicePciBusInfoKhr, Iterable { + public long size() { + return segment.byteSize() / CLDevicePciBusInfoKhr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLDevicePciBusInfoKhr at(long index) { + return new CLDevicePciBusInfoKhr(segment.asSlice(index * CLDevicePciBusInfoKhr.BYTES, CLDevicePciBusInfoKhr.BYTES)); + } + + public CLDevicePciBusInfoKhr.Ptr at(long index, @NotNull Consumer<@NotNull CLDevicePciBusInfoKhr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLDevicePciBusInfoKhr value) { + MemorySegment s = segment.asSlice(index * CLDevicePciBusInfoKhr.BYTES, CLDevicePciBusInfoKhr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLDevicePciBusInfoKhr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLDevicePciBusInfoKhr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLDevicePciBusInfoKhr.BYTES, + (end - start) * CLDevicePciBusInfoKhr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLDevicePciBusInfoKhr.BYTES)); + } + + public CLDevicePciBusInfoKhr[] toArray() { + CLDevicePciBusInfoKhr[] ret = new CLDevicePciBusInfoKhr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLDevicePciBusInfoKhr.BYTES; + } + + @Override + public CLDevicePciBusInfoKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLDevicePciBusInfoKhr ret = new CLDevicePciBusInfoKhr(segment.asSlice(0, CLDevicePciBusInfoKhr.BYTES)); + segment = segment.asSlice(CLDevicePciBusInfoKhr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLDevicePciBusInfoKhr allocate(Arena arena) { + return new CLDevicePciBusInfoKhr(arena.allocate(LAYOUT)); + } + + public static CLDevicePciBusInfoKhr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLDevicePciBusInfoKhr.Ptr(segment); + } + + public static CLDevicePciBusInfoKhr clone(Arena arena, CLDevicePciBusInfoKhr src) { + CLDevicePciBusInfoKhr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_uint") @Unsigned int pciDomain() { + return segment.get(LAYOUT$pciDomain, OFFSET$pciDomain); + } + + public CLDevicePciBusInfoKhr pciDomain(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$pciDomain, OFFSET$pciDomain, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int pciBus() { + return segment.get(LAYOUT$pciBus, OFFSET$pciBus); + } + + public CLDevicePciBusInfoKhr pciBus(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$pciBus, OFFSET$pciBus, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int pciDevice() { + return segment.get(LAYOUT$pciDevice, OFFSET$pciDevice); + } + + public CLDevicePciBusInfoKhr pciDevice(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$pciDevice, OFFSET$pciDevice, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int pciFunction() { + return segment.get(LAYOUT$pciFunction, OFFSET$pciFunction); + } + + public CLDevicePciBusInfoKhr pciFunction(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$pciFunction, OFFSET$pciFunction, value); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("pciDomain"), + ValueLayout.JAVA_INT.withName("pciBus"), + ValueLayout.JAVA_INT.withName("pciDevice"), + ValueLayout.JAVA_INT.withName("pciFunction") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$pciDomain = PathElement.groupElement("pciDomain"); + public static final PathElement PATH$pciBus = PathElement.groupElement("pciBus"); + public static final PathElement PATH$pciDevice = PathElement.groupElement("pciDevice"); + public static final PathElement PATH$pciFunction = PathElement.groupElement("pciFunction"); + + public static final OfInt LAYOUT$pciDomain = (OfInt) LAYOUT.select(PATH$pciDomain); + public static final OfInt LAYOUT$pciBus = (OfInt) LAYOUT.select(PATH$pciBus); + public static final OfInt LAYOUT$pciDevice = (OfInt) LAYOUT.select(PATH$pciDevice); + public static final OfInt LAYOUT$pciFunction = (OfInt) LAYOUT.select(PATH$pciFunction); + + public static final long SIZE$pciDomain = LAYOUT$pciDomain.byteSize(); + public static final long SIZE$pciBus = LAYOUT$pciBus.byteSize(); + public static final long SIZE$pciDevice = LAYOUT$pciDevice.byteSize(); + public static final long SIZE$pciFunction = LAYOUT$pciFunction.byteSize(); + + public static final long OFFSET$pciDomain = LAYOUT.byteOffset(PATH$pciDomain); + public static final long OFFSET$pciBus = LAYOUT.byteOffset(PATH$pciBus); + public static final long OFFSET$pciDevice = LAYOUT.byteOffset(PATH$pciDevice); + public static final long OFFSET$pciFunction = LAYOUT.byteOffset(PATH$pciFunction); +} diff --git a/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr$Ptr$Iter.class new file mode 100644 index 0000000..56d5cd0 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr$Ptr.class b/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr$Ptr.class new file mode 100644 index 0000000..8831b3b Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr.class b/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr.class new file mode 100644 index 0000000..ef8eb32 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr.class differ diff --git a/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr.java b/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr.java new file mode 100644 index 0000000..1f83f0a --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLDx9SurfaceInfoKhr.java @@ -0,0 +1,233 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_dx9_surface_info_khr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_dx9_surface_info_khr { +/// IDirect3DSurface9* resource; // @link substring="resource" target="#resource" +/// HANDLE sharedHandle; // @link substring="sharedHandle" target="#sharedHandle" +/// } cl_dx9_surface_info_khr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_dx9_surface_info_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLDx9SurfaceInfoKhr(@NotNull MemorySegment segment) implements ICLDx9SurfaceInfoKhr { + /// Represents a pointer to / an array of cl_dx9_surface_info_khr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLDx9SurfaceInfoKhr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLDx9SurfaceInfoKhr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLDx9SurfaceInfoKhr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLDx9SurfaceInfoKhr, Iterable { + public long size() { + return segment.byteSize() / CLDx9SurfaceInfoKhr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLDx9SurfaceInfoKhr at(long index) { + return new CLDx9SurfaceInfoKhr(segment.asSlice(index * CLDx9SurfaceInfoKhr.BYTES, CLDx9SurfaceInfoKhr.BYTES)); + } + + public CLDx9SurfaceInfoKhr.Ptr at(long index, @NotNull Consumer<@NotNull CLDx9SurfaceInfoKhr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLDx9SurfaceInfoKhr value) { + MemorySegment s = segment.asSlice(index * CLDx9SurfaceInfoKhr.BYTES, CLDx9SurfaceInfoKhr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLDx9SurfaceInfoKhr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLDx9SurfaceInfoKhr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLDx9SurfaceInfoKhr.BYTES, + (end - start) * CLDx9SurfaceInfoKhr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLDx9SurfaceInfoKhr.BYTES)); + } + + public CLDx9SurfaceInfoKhr[] toArray() { + CLDx9SurfaceInfoKhr[] ret = new CLDx9SurfaceInfoKhr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLDx9SurfaceInfoKhr.BYTES; + } + + @Override + public CLDx9SurfaceInfoKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLDx9SurfaceInfoKhr ret = new CLDx9SurfaceInfoKhr(segment.asSlice(0, CLDx9SurfaceInfoKhr.BYTES)); + segment = segment.asSlice(CLDx9SurfaceInfoKhr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLDx9SurfaceInfoKhr allocate(Arena arena) { + return new CLDx9SurfaceInfoKhr(arena.allocate(LAYOUT)); + } + + public static CLDx9SurfaceInfoKhr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLDx9SurfaceInfoKhr.Ptr(segment); + } + + public static CLDx9SurfaceInfoKhr clone(Arena arena, CLDx9SurfaceInfoKhr src) { + CLDx9SurfaceInfoKhr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + /// Note: the returned {@link PointerPtr} does not have correct {@link PointerPtr#size} property. It's up + /// to user to track the size of the buffer, and use {@link PointerPtr#reinterpret} to set the size before + /// actually reading from or writing to the buffer. + public @Nullable PointerPtr resource() { + MemorySegment s = resourceRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new PointerPtr(s); + } + + public CLDx9SurfaceInfoKhr resource(@Nullable PointerPtr value) { + MemorySegment s = value == null ? MemorySegment.NULL : value.segment(); + resourceRaw(s); + return this; + } + + public @Pointer(comment="IDirect3DSurface9*") @NotNull MemorySegment resourceRaw() { + return segment.get(LAYOUT$resource, OFFSET$resource); + } + + public void resourceRaw(@Pointer(comment="IDirect3DSurface9*") @NotNull MemorySegment value) { + segment.set(LAYOUT$resource, OFFSET$resource, value); + } + + public @Pointer(comment="HANDLE") @NotNull MemorySegment sharedHandle() { + return segment.get(LAYOUT$sharedHandle, OFFSET$sharedHandle); + } + + public CLDx9SurfaceInfoKhr sharedHandle(@Pointer(comment="HANDLE") @NotNull MemorySegment value) { + segment.set(LAYOUT$sharedHandle, OFFSET$sharedHandle, value); + return this; + } + + public CLDx9SurfaceInfoKhr sharedHandle(@Nullable IPointer pointer) { + sharedHandle(pointer != null ? pointer.segment() : MemorySegment.NULL); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.ADDRESS.withTargetLayout(ValueLayout.ADDRESS).withName("resource"), + ValueLayout.ADDRESS.withName("sharedHandle") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$resource = PathElement.groupElement("resource"); + public static final PathElement PATH$sharedHandle = PathElement.groupElement("sharedHandle"); + + public static final AddressLayout LAYOUT$resource = (AddressLayout) LAYOUT.select(PATH$resource); + public static final AddressLayout LAYOUT$sharedHandle = (AddressLayout) LAYOUT.select(PATH$sharedHandle); + + public static final long SIZE$resource = LAYOUT$resource.byteSize(); + public static final long SIZE$sharedHandle = LAYOUT$sharedHandle.byteSize(); + + public static final long OFFSET$resource = LAYOUT.byteOffset(PATH$resource); + public static final long OFFSET$sharedHandle = LAYOUT.byteOffset(PATH$sharedHandle); +} diff --git a/src/club/doki7/opencl/datatype/CLImageDesc$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLImageDesc$Ptr$Iter.class new file mode 100644 index 0000000..9331ea2 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageDesc$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageDesc$Ptr.class b/src/club/doki7/opencl/datatype/CLImageDesc$Ptr.class new file mode 100644 index 0000000..282dde6 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageDesc$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageDesc.class b/src/club/doki7/opencl/datatype/CLImageDesc.class new file mode 100644 index 0000000..1015e66 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageDesc.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageDesc.java b/src/club/doki7/opencl/datatype/CLImageDesc.java new file mode 100644 index 0000000..85cd741 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLImageDesc.java @@ -0,0 +1,331 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_image_desc structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_image_desc { +/// cl_mem_object_type imageType; // @link substring="imageType" target="#imageType" +/// size_t imageWidth; // @link substring="imageWidth" target="#imageWidth" +/// size_t imageHeight; // @link substring="imageHeight" target="#imageHeight" +/// size_t imageDepth; // @link substring="imageDepth" target="#imageDepth" +/// size_t imageArraySize; // @link substring="imageArraySize" target="#imageArraySize" +/// size_t imageRowPitch; // @link substring="imageRowPitch" target="#imageRowPitch" +/// size_t imageSlicePitch; // @link substring="imageSlicePitch" target="#imageSlicePitch" +/// cl_uint numMipLevels; // @link substring="numMipLevels" target="#numMipLevels" +/// cl_uint numSamples; // @link substring="numSamples" target="#numSamples" +/// cl_image_desc_buffer_or_mem_object bufferOrMemObject; // @link substring="CLImageDescBufferOrMemObject" target="CLImageDescBufferOrMemObject" @link substring="bufferOrMemObject" target="#bufferOrMemObject" +/// } cl_image_desc; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_image_desc +@ValueBasedCandidate +@UnsafeConstructor +public record CLImageDesc(@NotNull MemorySegment segment) implements ICLImageDesc { + /// Represents a pointer to / an array of cl_image_desc structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLImageDesc}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLImageDesc to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLImageDesc.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLImageDesc, Iterable { + public long size() { + return segment.byteSize() / CLImageDesc.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLImageDesc at(long index) { + return new CLImageDesc(segment.asSlice(index * CLImageDesc.BYTES, CLImageDesc.BYTES)); + } + + public CLImageDesc.Ptr at(long index, @NotNull Consumer<@NotNull CLImageDesc> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLImageDesc value) { + MemorySegment s = segment.asSlice(index * CLImageDesc.BYTES, CLImageDesc.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLImageDesc.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLImageDesc.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLImageDesc.BYTES, + (end - start) * CLImageDesc.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLImageDesc.BYTES)); + } + + public CLImageDesc[] toArray() { + CLImageDesc[] ret = new CLImageDesc[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLImageDesc.BYTES; + } + + @Override + public CLImageDesc next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLImageDesc ret = new CLImageDesc(segment.asSlice(0, CLImageDesc.BYTES)); + segment = segment.asSlice(CLImageDesc.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLImageDesc allocate(Arena arena) { + return new CLImageDesc(arena.allocate(LAYOUT)); + } + + public static CLImageDesc.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLImageDesc.Ptr(segment); + } + + public static CLImageDesc clone(Arena arena, CLImageDesc src) { + CLImageDesc ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_mem_object_type") @Unsigned int imageType() { + return segment.get(LAYOUT$imageType, OFFSET$imageType); + } + + public CLImageDesc imageType(@NativeType("cl_mem_object_type") @Unsigned int value) { + segment.set(LAYOUT$imageType, OFFSET$imageType, value); + return this; + } + + public @Unsigned long imageWidth() { + return NativeLayout.readCSizeT(segment, OFFSET$imageWidth); + } + + public CLImageDesc imageWidth(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$imageWidth, value); + return this; + } + + public @Unsigned long imageHeight() { + return NativeLayout.readCSizeT(segment, OFFSET$imageHeight); + } + + public CLImageDesc imageHeight(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$imageHeight, value); + return this; + } + + public @Unsigned long imageDepth() { + return NativeLayout.readCSizeT(segment, OFFSET$imageDepth); + } + + public CLImageDesc imageDepth(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$imageDepth, value); + return this; + } + + public @Unsigned long imageArraySize() { + return NativeLayout.readCSizeT(segment, OFFSET$imageArraySize); + } + + public CLImageDesc imageArraySize(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$imageArraySize, value); + return this; + } + + public @Unsigned long imageRowPitch() { + return NativeLayout.readCSizeT(segment, OFFSET$imageRowPitch); + } + + public CLImageDesc imageRowPitch(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$imageRowPitch, value); + return this; + } + + public @Unsigned long imageSlicePitch() { + return NativeLayout.readCSizeT(segment, OFFSET$imageSlicePitch); + } + + public CLImageDesc imageSlicePitch(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$imageSlicePitch, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int numMipLevels() { + return segment.get(LAYOUT$numMipLevels, OFFSET$numMipLevels); + } + + public CLImageDesc numMipLevels(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$numMipLevels, OFFSET$numMipLevels, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int numSamples() { + return segment.get(LAYOUT$numSamples, OFFSET$numSamples); + } + + public CLImageDesc numSamples(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$numSamples, OFFSET$numSamples, value); + return this; + } + + public @NotNull CLImageDescBufferOrMemObject bufferOrMemObject() { + return new CLImageDescBufferOrMemObject(segment.asSlice(OFFSET$bufferOrMemObject, LAYOUT$bufferOrMemObject)); + } + + public CLImageDesc bufferOrMemObject(@NotNull CLImageDescBufferOrMemObject value) { + MemorySegment.copy(value.segment(), 0, segment, OFFSET$bufferOrMemObject, SIZE$bufferOrMemObject); + return this; + } + + public CLImageDesc bufferOrMemObject(Consumer<@NotNull CLImageDescBufferOrMemObject> consumer) { + consumer.accept(bufferOrMemObject()); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("imageType"), + NativeLayout.C_SIZE_T.withName("imageWidth"), + NativeLayout.C_SIZE_T.withName("imageHeight"), + NativeLayout.C_SIZE_T.withName("imageDepth"), + NativeLayout.C_SIZE_T.withName("imageArraySize"), + NativeLayout.C_SIZE_T.withName("imageRowPitch"), + NativeLayout.C_SIZE_T.withName("imageSlicePitch"), + ValueLayout.JAVA_INT.withName("numMipLevels"), + ValueLayout.JAVA_INT.withName("numSamples"), + CLImageDescBufferOrMemObject.LAYOUT.withName("bufferOrMemObject") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$imageType = PathElement.groupElement("imageType"); + public static final PathElement PATH$imageWidth = PathElement.groupElement("imageWidth"); + public static final PathElement PATH$imageHeight = PathElement.groupElement("imageHeight"); + public static final PathElement PATH$imageDepth = PathElement.groupElement("imageDepth"); + public static final PathElement PATH$imageArraySize = PathElement.groupElement("imageArraySize"); + public static final PathElement PATH$imageRowPitch = PathElement.groupElement("imageRowPitch"); + public static final PathElement PATH$imageSlicePitch = PathElement.groupElement("imageSlicePitch"); + public static final PathElement PATH$numMipLevels = PathElement.groupElement("numMipLevels"); + public static final PathElement PATH$numSamples = PathElement.groupElement("numSamples"); + public static final PathElement PATH$bufferOrMemObject = PathElement.groupElement("bufferOrMemObject"); + + public static final OfInt LAYOUT$imageType = (OfInt) LAYOUT.select(PATH$imageType); + public static final OfInt LAYOUT$numMipLevels = (OfInt) LAYOUT.select(PATH$numMipLevels); + public static final OfInt LAYOUT$numSamples = (OfInt) LAYOUT.select(PATH$numSamples); + public static final UnionLayout LAYOUT$bufferOrMemObject = (UnionLayout) LAYOUT.select(PATH$bufferOrMemObject); + + public static final long SIZE$imageType = LAYOUT$imageType.byteSize(); + public static final long SIZE$imageWidth = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$imageHeight = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$imageDepth = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$imageArraySize = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$imageRowPitch = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$imageSlicePitch = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$numMipLevels = LAYOUT$numMipLevels.byteSize(); + public static final long SIZE$numSamples = LAYOUT$numSamples.byteSize(); + public static final long SIZE$bufferOrMemObject = LAYOUT$bufferOrMemObject.byteSize(); + + public static final long OFFSET$imageType = LAYOUT.byteOffset(PATH$imageType); + public static final long OFFSET$imageWidth = LAYOUT.byteOffset(PATH$imageWidth); + public static final long OFFSET$imageHeight = LAYOUT.byteOffset(PATH$imageHeight); + public static final long OFFSET$imageDepth = LAYOUT.byteOffset(PATH$imageDepth); + public static final long OFFSET$imageArraySize = LAYOUT.byteOffset(PATH$imageArraySize); + public static final long OFFSET$imageRowPitch = LAYOUT.byteOffset(PATH$imageRowPitch); + public static final long OFFSET$imageSlicePitch = LAYOUT.byteOffset(PATH$imageSlicePitch); + public static final long OFFSET$numMipLevels = LAYOUT.byteOffset(PATH$numMipLevels); + public static final long OFFSET$numSamples = LAYOUT.byteOffset(PATH$numSamples); + public static final long OFFSET$bufferOrMemObject = LAYOUT.byteOffset(PATH$bufferOrMemObject); +} diff --git a/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject$Ptr$Iter.class new file mode 100644 index 0000000..8f01001 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject$Ptr.class b/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject$Ptr.class new file mode 100644 index 0000000..5669db4 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject.class b/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject.class new file mode 100644 index 0000000..0dd536f Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject.java b/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject.java new file mode 100644 index 0000000..89584a2 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLImageDescBufferOrMemObject.java @@ -0,0 +1,220 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_image_desc_buffer_or_mem_object structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef union cl_image_desc_buffer_or_mem_object { +/// cl_mem buffer; // @link substring="CLMem" target="CLMem" @link substring="buffer" target="#buffer" +/// cl_mem memObject; // @link substring="CLMem" target="CLMem" @link substring="memObject" target="#memObject" +/// } cl_image_desc_buffer_or_mem_object; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_image_desc_buffer_or_mem_object +@ValueBasedCandidate +@UnsafeConstructor +public record CLImageDescBufferOrMemObject(@NotNull MemorySegment segment) implements ICLImageDescBufferOrMemObject { + /// Represents a pointer to / an array of cl_image_desc_buffer_or_mem_object structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLImageDescBufferOrMemObject}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLImageDescBufferOrMemObject to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLImageDescBufferOrMemObject.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLImageDescBufferOrMemObject, Iterable { + public long size() { + return segment.byteSize() / CLImageDescBufferOrMemObject.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLImageDescBufferOrMemObject at(long index) { + return new CLImageDescBufferOrMemObject(segment.asSlice(index * CLImageDescBufferOrMemObject.BYTES, CLImageDescBufferOrMemObject.BYTES)); + } + + public CLImageDescBufferOrMemObject.Ptr at(long index, @NotNull Consumer<@NotNull CLImageDescBufferOrMemObject> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLImageDescBufferOrMemObject value) { + MemorySegment s = segment.asSlice(index * CLImageDescBufferOrMemObject.BYTES, CLImageDescBufferOrMemObject.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLImageDescBufferOrMemObject.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLImageDescBufferOrMemObject.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLImageDescBufferOrMemObject.BYTES, + (end - start) * CLImageDescBufferOrMemObject.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLImageDescBufferOrMemObject.BYTES)); + } + + public CLImageDescBufferOrMemObject[] toArray() { + CLImageDescBufferOrMemObject[] ret = new CLImageDescBufferOrMemObject[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLImageDescBufferOrMemObject.BYTES; + } + + @Override + public CLImageDescBufferOrMemObject next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLImageDescBufferOrMemObject ret = new CLImageDescBufferOrMemObject(segment.asSlice(0, CLImageDescBufferOrMemObject.BYTES)); + segment = segment.asSlice(CLImageDescBufferOrMemObject.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLImageDescBufferOrMemObject allocate(Arena arena) { + return new CLImageDescBufferOrMemObject(arena.allocate(LAYOUT)); + } + + public static CLImageDescBufferOrMemObject.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLImageDescBufferOrMemObject.Ptr(segment); + } + + public static CLImageDescBufferOrMemObject clone(Arena arena, CLImageDescBufferOrMemObject src) { + CLImageDescBufferOrMemObject ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @Nullable CLMem buffer() { + MemorySegment s = segment.asSlice(OFFSET$buffer, SIZE$buffer); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMem(s); + } + + public CLImageDescBufferOrMemObject buffer(@Nullable CLMem value) { + segment.set(LAYOUT$buffer, OFFSET$buffer, value != null ? value.segment() : MemorySegment.NULL); + return this; + } + + public @Nullable CLMem memObject() { + MemorySegment s = segment.asSlice(OFFSET$memObject, SIZE$memObject); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMem(s); + } + + public CLImageDescBufferOrMemObject memObject(@Nullable CLMem value) { + segment.set(LAYOUT$memObject, OFFSET$memObject, value != null ? value.segment() : MemorySegment.NULL); + return this; + } + + public static final UnionLayout LAYOUT = NativeLayout.unionLayout( + ValueLayout.ADDRESS.withName("buffer"), + ValueLayout.ADDRESS.withName("memObject") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$buffer = PathElement.groupElement("buffer"); + public static final PathElement PATH$memObject = PathElement.groupElement("memObject"); + + public static final AddressLayout LAYOUT$buffer = (AddressLayout) LAYOUT.select(PATH$buffer); + public static final AddressLayout LAYOUT$memObject = (AddressLayout) LAYOUT.select(PATH$memObject); + + public static final long SIZE$buffer = LAYOUT$buffer.byteSize(); + public static final long SIZE$memObject = LAYOUT$memObject.byteSize(); + + public static final long OFFSET$buffer = LAYOUT.byteOffset(PATH$buffer); + public static final long OFFSET$memObject = LAYOUT.byteOffset(PATH$memObject); +} diff --git a/src/club/doki7/opencl/datatype/CLImageFormat$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLImageFormat$Ptr$Iter.class new file mode 100644 index 0000000..a442e09 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageFormat$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageFormat$Ptr.class b/src/club/doki7/opencl/datatype/CLImageFormat$Ptr.class new file mode 100644 index 0000000..3ec573e Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageFormat$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageFormat.class b/src/club/doki7/opencl/datatype/CLImageFormat.class new file mode 100644 index 0000000..c260c29 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLImageFormat.class differ diff --git a/src/club/doki7/opencl/datatype/CLImageFormat.java b/src/club/doki7/opencl/datatype/CLImageFormat.java new file mode 100644 index 0000000..d363fb0 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLImageFormat.java @@ -0,0 +1,212 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_image_format structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_image_format { +/// cl_channel_order imageChannelOrder; // @link substring="imageChannelOrder" target="#imageChannelOrder" +/// cl_channel_type imageChannelDataType; // @link substring="imageChannelDataType" target="#imageChannelDataType" +/// } cl_image_format; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_image_format +@ValueBasedCandidate +@UnsafeConstructor +public record CLImageFormat(@NotNull MemorySegment segment) implements ICLImageFormat { + /// Represents a pointer to / an array of cl_image_format structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLImageFormat}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLImageFormat to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLImageFormat.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLImageFormat, Iterable { + public long size() { + return segment.byteSize() / CLImageFormat.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLImageFormat at(long index) { + return new CLImageFormat(segment.asSlice(index * CLImageFormat.BYTES, CLImageFormat.BYTES)); + } + + public CLImageFormat.Ptr at(long index, @NotNull Consumer<@NotNull CLImageFormat> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLImageFormat value) { + MemorySegment s = segment.asSlice(index * CLImageFormat.BYTES, CLImageFormat.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLImageFormat.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLImageFormat.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLImageFormat.BYTES, + (end - start) * CLImageFormat.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLImageFormat.BYTES)); + } + + public CLImageFormat[] toArray() { + CLImageFormat[] ret = new CLImageFormat[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLImageFormat.BYTES; + } + + @Override + public CLImageFormat next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLImageFormat ret = new CLImageFormat(segment.asSlice(0, CLImageFormat.BYTES)); + segment = segment.asSlice(CLImageFormat.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLImageFormat allocate(Arena arena) { + return new CLImageFormat(arena.allocate(LAYOUT)); + } + + public static CLImageFormat.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLImageFormat.Ptr(segment); + } + + public static CLImageFormat clone(Arena arena, CLImageFormat src) { + CLImageFormat ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_channel_order") @Unsigned int imageChannelOrder() { + return segment.get(LAYOUT$imageChannelOrder, OFFSET$imageChannelOrder); + } + + public CLImageFormat imageChannelOrder(@NativeType("cl_channel_order") @Unsigned int value) { + segment.set(LAYOUT$imageChannelOrder, OFFSET$imageChannelOrder, value); + return this; + } + + public @NativeType("cl_channel_type") @Unsigned int imageChannelDataType() { + return segment.get(LAYOUT$imageChannelDataType, OFFSET$imageChannelDataType); + } + + public CLImageFormat imageChannelDataType(@NativeType("cl_channel_type") @Unsigned int value) { + segment.set(LAYOUT$imageChannelDataType, OFFSET$imageChannelDataType, value); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("imageChannelOrder"), + ValueLayout.JAVA_INT.withName("imageChannelDataType") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$imageChannelOrder = PathElement.groupElement("imageChannelOrder"); + public static final PathElement PATH$imageChannelDataType = PathElement.groupElement("imageChannelDataType"); + + public static final OfInt LAYOUT$imageChannelOrder = (OfInt) LAYOUT.select(PATH$imageChannelOrder); + public static final OfInt LAYOUT$imageChannelDataType = (OfInt) LAYOUT.select(PATH$imageChannelDataType); + + public static final long SIZE$imageChannelOrder = LAYOUT$imageChannelOrder.byteSize(); + public static final long SIZE$imageChannelDataType = LAYOUT$imageChannelDataType.byteSize(); + + public static final long OFFSET$imageChannelOrder = LAYOUT.byteOffset(PATH$imageChannelOrder); + public static final long OFFSET$imageChannelDataType = LAYOUT.byteOffset(PATH$imageChannelDataType); +} diff --git a/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr$Ptr$Iter.class new file mode 100644 index 0000000..a2eeb8f Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr$Ptr.class b/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr$Ptr.class new file mode 100644 index 0000000..4c5ad66 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr.class b/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr.class new file mode 100644 index 0000000..00d86af Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr.java b/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr.java new file mode 100644 index 0000000..a1d5b93 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLMemAndroidNativeBufferHostPtr.java @@ -0,0 +1,222 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_mem_android_native_buffer_host_ptr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_mem_android_native_buffer_host_ptr { +/// cl_mem_ext_host_ptr extHostPtr; // @link substring="CLMemExtHostPtr" target="CLMemExtHostPtr" @link substring="extHostPtr" target="#extHostPtr" +/// void* anbPtr; // @link substring="anbPtr" target="#anbPtr" +/// } cl_mem_android_native_buffer_host_ptr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_mem_android_native_buffer_host_ptr +@ValueBasedCandidate +@UnsafeConstructor +public record CLMemAndroidNativeBufferHostPtr(@NotNull MemorySegment segment) implements ICLMemAndroidNativeBufferHostPtr { + /// Represents a pointer to / an array of cl_mem_android_native_buffer_host_ptr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLMemAndroidNativeBufferHostPtr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLMemAndroidNativeBufferHostPtr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLMemAndroidNativeBufferHostPtr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLMemAndroidNativeBufferHostPtr, Iterable { + public long size() { + return segment.byteSize() / CLMemAndroidNativeBufferHostPtr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLMemAndroidNativeBufferHostPtr at(long index) { + return new CLMemAndroidNativeBufferHostPtr(segment.asSlice(index * CLMemAndroidNativeBufferHostPtr.BYTES, CLMemAndroidNativeBufferHostPtr.BYTES)); + } + + public CLMemAndroidNativeBufferHostPtr.Ptr at(long index, @NotNull Consumer<@NotNull CLMemAndroidNativeBufferHostPtr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLMemAndroidNativeBufferHostPtr value) { + MemorySegment s = segment.asSlice(index * CLMemAndroidNativeBufferHostPtr.BYTES, CLMemAndroidNativeBufferHostPtr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLMemAndroidNativeBufferHostPtr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLMemAndroidNativeBufferHostPtr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLMemAndroidNativeBufferHostPtr.BYTES, + (end - start) * CLMemAndroidNativeBufferHostPtr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLMemAndroidNativeBufferHostPtr.BYTES)); + } + + public CLMemAndroidNativeBufferHostPtr[] toArray() { + CLMemAndroidNativeBufferHostPtr[] ret = new CLMemAndroidNativeBufferHostPtr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLMemAndroidNativeBufferHostPtr.BYTES; + } + + @Override + public CLMemAndroidNativeBufferHostPtr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLMemAndroidNativeBufferHostPtr ret = new CLMemAndroidNativeBufferHostPtr(segment.asSlice(0, CLMemAndroidNativeBufferHostPtr.BYTES)); + segment = segment.asSlice(CLMemAndroidNativeBufferHostPtr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLMemAndroidNativeBufferHostPtr allocate(Arena arena) { + return new CLMemAndroidNativeBufferHostPtr(arena.allocate(LAYOUT)); + } + + public static CLMemAndroidNativeBufferHostPtr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLMemAndroidNativeBufferHostPtr.Ptr(segment); + } + + public static CLMemAndroidNativeBufferHostPtr clone(Arena arena, CLMemAndroidNativeBufferHostPtr src) { + CLMemAndroidNativeBufferHostPtr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NotNull CLMemExtHostPtr extHostPtr() { + return new CLMemExtHostPtr(segment.asSlice(OFFSET$extHostPtr, LAYOUT$extHostPtr)); + } + + public CLMemAndroidNativeBufferHostPtr extHostPtr(@NotNull CLMemExtHostPtr value) { + MemorySegment.copy(value.segment(), 0, segment, OFFSET$extHostPtr, SIZE$extHostPtr); + return this; + } + + public CLMemAndroidNativeBufferHostPtr extHostPtr(Consumer<@NotNull CLMemExtHostPtr> consumer) { + consumer.accept(extHostPtr()); + return this; + } + + public @Pointer(comment="void*") @NotNull MemorySegment anbPtr() { + return segment.get(LAYOUT$anbPtr, OFFSET$anbPtr); + } + + public CLMemAndroidNativeBufferHostPtr anbPtr(@Pointer(comment="void*") @NotNull MemorySegment value) { + segment.set(LAYOUT$anbPtr, OFFSET$anbPtr, value); + return this; + } + + public CLMemAndroidNativeBufferHostPtr anbPtr(@Nullable IPointer pointer) { + anbPtr(pointer != null ? pointer.segment() : MemorySegment.NULL); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + CLMemExtHostPtr.LAYOUT.withName("extHostPtr"), + ValueLayout.ADDRESS.withName("anbPtr") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$extHostPtr = PathElement.groupElement("extHostPtr"); + public static final PathElement PATH$anbPtr = PathElement.groupElement("anbPtr"); + + public static final StructLayout LAYOUT$extHostPtr = (StructLayout) LAYOUT.select(PATH$extHostPtr); + public static final AddressLayout LAYOUT$anbPtr = (AddressLayout) LAYOUT.select(PATH$anbPtr); + + public static final long SIZE$extHostPtr = LAYOUT$extHostPtr.byteSize(); + public static final long SIZE$anbPtr = LAYOUT$anbPtr.byteSize(); + + public static final long OFFSET$extHostPtr = LAYOUT.byteOffset(PATH$extHostPtr); + public static final long OFFSET$anbPtr = LAYOUT.byteOffset(PATH$anbPtr); +} diff --git a/src/club/doki7/opencl/datatype/CLMemExtHostPtr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLMemExtHostPtr$Ptr$Iter.class new file mode 100644 index 0000000..87218c5 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemExtHostPtr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemExtHostPtr$Ptr.class b/src/club/doki7/opencl/datatype/CLMemExtHostPtr$Ptr.class new file mode 100644 index 0000000..a45db52 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemExtHostPtr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemExtHostPtr.class b/src/club/doki7/opencl/datatype/CLMemExtHostPtr.class new file mode 100644 index 0000000..0213198 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemExtHostPtr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemExtHostPtr.java b/src/club/doki7/opencl/datatype/CLMemExtHostPtr.java new file mode 100644 index 0000000..c9c0368 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLMemExtHostPtr.java @@ -0,0 +1,212 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_mem_ext_host_ptr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_mem_ext_host_ptr { +/// cl_uint allocationType; // @link substring="allocationType" target="#allocationType" +/// cl_uint hostCachePolicy; // @link substring="hostCachePolicy" target="#hostCachePolicy" +/// } cl_mem_ext_host_ptr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_mem_ext_host_ptr +@ValueBasedCandidate +@UnsafeConstructor +public record CLMemExtHostPtr(@NotNull MemorySegment segment) implements ICLMemExtHostPtr { + /// Represents a pointer to / an array of cl_mem_ext_host_ptr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLMemExtHostPtr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLMemExtHostPtr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLMemExtHostPtr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLMemExtHostPtr, Iterable { + public long size() { + return segment.byteSize() / CLMemExtHostPtr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLMemExtHostPtr at(long index) { + return new CLMemExtHostPtr(segment.asSlice(index * CLMemExtHostPtr.BYTES, CLMemExtHostPtr.BYTES)); + } + + public CLMemExtHostPtr.Ptr at(long index, @NotNull Consumer<@NotNull CLMemExtHostPtr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLMemExtHostPtr value) { + MemorySegment s = segment.asSlice(index * CLMemExtHostPtr.BYTES, CLMemExtHostPtr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLMemExtHostPtr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLMemExtHostPtr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLMemExtHostPtr.BYTES, + (end - start) * CLMemExtHostPtr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLMemExtHostPtr.BYTES)); + } + + public CLMemExtHostPtr[] toArray() { + CLMemExtHostPtr[] ret = new CLMemExtHostPtr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLMemExtHostPtr.BYTES; + } + + @Override + public CLMemExtHostPtr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLMemExtHostPtr ret = new CLMemExtHostPtr(segment.asSlice(0, CLMemExtHostPtr.BYTES)); + segment = segment.asSlice(CLMemExtHostPtr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLMemExtHostPtr allocate(Arena arena) { + return new CLMemExtHostPtr(arena.allocate(LAYOUT)); + } + + public static CLMemExtHostPtr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLMemExtHostPtr.Ptr(segment); + } + + public static CLMemExtHostPtr clone(Arena arena, CLMemExtHostPtr src) { + CLMemExtHostPtr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_uint") @Unsigned int allocationType() { + return segment.get(LAYOUT$allocationType, OFFSET$allocationType); + } + + public CLMemExtHostPtr allocationType(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$allocationType, OFFSET$allocationType, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int hostCachePolicy() { + return segment.get(LAYOUT$hostCachePolicy, OFFSET$hostCachePolicy); + } + + public CLMemExtHostPtr hostCachePolicy(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$hostCachePolicy, OFFSET$hostCachePolicy, value); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("allocationType"), + ValueLayout.JAVA_INT.withName("hostCachePolicy") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$allocationType = PathElement.groupElement("allocationType"); + public static final PathElement PATH$hostCachePolicy = PathElement.groupElement("hostCachePolicy"); + + public static final OfInt LAYOUT$allocationType = (OfInt) LAYOUT.select(PATH$allocationType); + public static final OfInt LAYOUT$hostCachePolicy = (OfInt) LAYOUT.select(PATH$hostCachePolicy); + + public static final long SIZE$allocationType = LAYOUT$allocationType.byteSize(); + public static final long SIZE$hostCachePolicy = LAYOUT$hostCachePolicy.byteSize(); + + public static final long OFFSET$allocationType = LAYOUT.byteOffset(PATH$allocationType); + public static final long OFFSET$hostCachePolicy = LAYOUT.byteOffset(PATH$hostCachePolicy); +} diff --git a/src/club/doki7/opencl/datatype/CLMemIonHostPtr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLMemIonHostPtr$Ptr$Iter.class new file mode 100644 index 0000000..020c950 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemIonHostPtr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemIonHostPtr$Ptr.class b/src/club/doki7/opencl/datatype/CLMemIonHostPtr$Ptr.class new file mode 100644 index 0000000..81c1711 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemIonHostPtr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemIonHostPtr.class b/src/club/doki7/opencl/datatype/CLMemIonHostPtr.class new file mode 100644 index 0000000..d8e7778 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMemIonHostPtr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMemIonHostPtr.java b/src/club/doki7/opencl/datatype/CLMemIonHostPtr.java new file mode 100644 index 0000000..7392ae3 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLMemIonHostPtr.java @@ -0,0 +1,237 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_mem_ion_host_ptr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_mem_ion_host_ptr { +/// cl_mem_ext_host_ptr extHostPtr; // @link substring="CLMemExtHostPtr" target="CLMemExtHostPtr" @link substring="extHostPtr" target="#extHostPtr" +/// int ionFiledesc; // @link substring="ionFiledesc" target="#ionFiledesc" +/// void* ionHostptr; // @link substring="ionHostptr" target="#ionHostptr" +/// } cl_mem_ion_host_ptr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_mem_ion_host_ptr +@ValueBasedCandidate +@UnsafeConstructor +public record CLMemIonHostPtr(@NotNull MemorySegment segment) implements ICLMemIonHostPtr { + /// Represents a pointer to / an array of cl_mem_ion_host_ptr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLMemIonHostPtr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLMemIonHostPtr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLMemIonHostPtr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLMemIonHostPtr, Iterable { + public long size() { + return segment.byteSize() / CLMemIonHostPtr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLMemIonHostPtr at(long index) { + return new CLMemIonHostPtr(segment.asSlice(index * CLMemIonHostPtr.BYTES, CLMemIonHostPtr.BYTES)); + } + + public CLMemIonHostPtr.Ptr at(long index, @NotNull Consumer<@NotNull CLMemIonHostPtr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLMemIonHostPtr value) { + MemorySegment s = segment.asSlice(index * CLMemIonHostPtr.BYTES, CLMemIonHostPtr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLMemIonHostPtr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLMemIonHostPtr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLMemIonHostPtr.BYTES, + (end - start) * CLMemIonHostPtr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLMemIonHostPtr.BYTES)); + } + + public CLMemIonHostPtr[] toArray() { + CLMemIonHostPtr[] ret = new CLMemIonHostPtr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLMemIonHostPtr.BYTES; + } + + @Override + public CLMemIonHostPtr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLMemIonHostPtr ret = new CLMemIonHostPtr(segment.asSlice(0, CLMemIonHostPtr.BYTES)); + segment = segment.asSlice(CLMemIonHostPtr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLMemIonHostPtr allocate(Arena arena) { + return new CLMemIonHostPtr(arena.allocate(LAYOUT)); + } + + public static CLMemIonHostPtr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLMemIonHostPtr.Ptr(segment); + } + + public static CLMemIonHostPtr clone(Arena arena, CLMemIonHostPtr src) { + CLMemIonHostPtr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NotNull CLMemExtHostPtr extHostPtr() { + return new CLMemExtHostPtr(segment.asSlice(OFFSET$extHostPtr, LAYOUT$extHostPtr)); + } + + public CLMemIonHostPtr extHostPtr(@NotNull CLMemExtHostPtr value) { + MemorySegment.copy(value.segment(), 0, segment, OFFSET$extHostPtr, SIZE$extHostPtr); + return this; + } + + public CLMemIonHostPtr extHostPtr(Consumer<@NotNull CLMemExtHostPtr> consumer) { + consumer.accept(extHostPtr()); + return this; + } + + public int ionFiledesc() { + return segment.get(LAYOUT$ionFiledesc, OFFSET$ionFiledesc); + } + + public CLMemIonHostPtr ionFiledesc(int value) { + segment.set(LAYOUT$ionFiledesc, OFFSET$ionFiledesc, value); + return this; + } + + public @Pointer(comment="void*") @NotNull MemorySegment ionHostptr() { + return segment.get(LAYOUT$ionHostptr, OFFSET$ionHostptr); + } + + public CLMemIonHostPtr ionHostptr(@Pointer(comment="void*") @NotNull MemorySegment value) { + segment.set(LAYOUT$ionHostptr, OFFSET$ionHostptr, value); + return this; + } + + public CLMemIonHostPtr ionHostptr(@Nullable IPointer pointer) { + ionHostptr(pointer != null ? pointer.segment() : MemorySegment.NULL); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + CLMemExtHostPtr.LAYOUT.withName("extHostPtr"), + ValueLayout.JAVA_INT.withName("ionFiledesc"), + ValueLayout.ADDRESS.withName("ionHostptr") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$extHostPtr = PathElement.groupElement("extHostPtr"); + public static final PathElement PATH$ionFiledesc = PathElement.groupElement("ionFiledesc"); + public static final PathElement PATH$ionHostptr = PathElement.groupElement("ionHostptr"); + + public static final StructLayout LAYOUT$extHostPtr = (StructLayout) LAYOUT.select(PATH$extHostPtr); + public static final OfInt LAYOUT$ionFiledesc = (OfInt) LAYOUT.select(PATH$ionFiledesc); + public static final AddressLayout LAYOUT$ionHostptr = (AddressLayout) LAYOUT.select(PATH$ionHostptr); + + public static final long SIZE$extHostPtr = LAYOUT$extHostPtr.byteSize(); + public static final long SIZE$ionFiledesc = LAYOUT$ionFiledesc.byteSize(); + public static final long SIZE$ionHostptr = LAYOUT$ionHostptr.byteSize(); + + public static final long OFFSET$extHostPtr = LAYOUT.byteOffset(PATH$extHostPtr); + public static final long OFFSET$ionFiledesc = LAYOUT.byteOffset(PATH$ionFiledesc); + public static final long OFFSET$ionHostptr = LAYOUT.byteOffset(PATH$ionHostptr); +} diff --git a/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel$Ptr$Iter.class new file mode 100644 index 0000000..5df6e86 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel$Ptr.class b/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel$Ptr.class new file mode 100644 index 0000000..99142e2 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel.class b/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel.class new file mode 100644 index 0000000..bc196b4 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel.class differ diff --git a/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel.java b/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel.java new file mode 100644 index 0000000..c80d38c --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLMotionEstimationDescIntel.java @@ -0,0 +1,242 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_motion_estimation_desc_intel structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_motion_estimation_desc_intel { +/// cl_uint mbBlockType; // @link substring="mbBlockType" target="#mbBlockType" +/// cl_uint subpixelMode; // @link substring="subpixelMode" target="#subpixelMode" +/// cl_uint sadAdjustMode; // @link substring="sadAdjustMode" target="#sadAdjustMode" +/// cl_uint searchPathType; // @link substring="searchPathType" target="#searchPathType" +/// } cl_motion_estimation_desc_intel; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_motion_estimation_desc_intel +@ValueBasedCandidate +@UnsafeConstructor +public record CLMotionEstimationDescIntel(@NotNull MemorySegment segment) implements ICLMotionEstimationDescIntel { + /// Represents a pointer to / an array of cl_motion_estimation_desc_intel structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLMotionEstimationDescIntel}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLMotionEstimationDescIntel to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLMotionEstimationDescIntel.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLMotionEstimationDescIntel, Iterable { + public long size() { + return segment.byteSize() / CLMotionEstimationDescIntel.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLMotionEstimationDescIntel at(long index) { + return new CLMotionEstimationDescIntel(segment.asSlice(index * CLMotionEstimationDescIntel.BYTES, CLMotionEstimationDescIntel.BYTES)); + } + + public CLMotionEstimationDescIntel.Ptr at(long index, @NotNull Consumer<@NotNull CLMotionEstimationDescIntel> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLMotionEstimationDescIntel value) { + MemorySegment s = segment.asSlice(index * CLMotionEstimationDescIntel.BYTES, CLMotionEstimationDescIntel.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLMotionEstimationDescIntel.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLMotionEstimationDescIntel.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLMotionEstimationDescIntel.BYTES, + (end - start) * CLMotionEstimationDescIntel.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLMotionEstimationDescIntel.BYTES)); + } + + public CLMotionEstimationDescIntel[] toArray() { + CLMotionEstimationDescIntel[] ret = new CLMotionEstimationDescIntel[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLMotionEstimationDescIntel.BYTES; + } + + @Override + public CLMotionEstimationDescIntel next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLMotionEstimationDescIntel ret = new CLMotionEstimationDescIntel(segment.asSlice(0, CLMotionEstimationDescIntel.BYTES)); + segment = segment.asSlice(CLMotionEstimationDescIntel.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLMotionEstimationDescIntel allocate(Arena arena) { + return new CLMotionEstimationDescIntel(arena.allocate(LAYOUT)); + } + + public static CLMotionEstimationDescIntel.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLMotionEstimationDescIntel.Ptr(segment); + } + + public static CLMotionEstimationDescIntel clone(Arena arena, CLMotionEstimationDescIntel src) { + CLMotionEstimationDescIntel ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_uint") @Unsigned int mbBlockType() { + return segment.get(LAYOUT$mbBlockType, OFFSET$mbBlockType); + } + + public CLMotionEstimationDescIntel mbBlockType(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$mbBlockType, OFFSET$mbBlockType, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int subpixelMode() { + return segment.get(LAYOUT$subpixelMode, OFFSET$subpixelMode); + } + + public CLMotionEstimationDescIntel subpixelMode(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$subpixelMode, OFFSET$subpixelMode, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int sadAdjustMode() { + return segment.get(LAYOUT$sadAdjustMode, OFFSET$sadAdjustMode); + } + + public CLMotionEstimationDescIntel sadAdjustMode(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$sadAdjustMode, OFFSET$sadAdjustMode, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int searchPathType() { + return segment.get(LAYOUT$searchPathType, OFFSET$searchPathType); + } + + public CLMotionEstimationDescIntel searchPathType(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$searchPathType, OFFSET$searchPathType, value); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("mbBlockType"), + ValueLayout.JAVA_INT.withName("subpixelMode"), + ValueLayout.JAVA_INT.withName("sadAdjustMode"), + ValueLayout.JAVA_INT.withName("searchPathType") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$mbBlockType = PathElement.groupElement("mbBlockType"); + public static final PathElement PATH$subpixelMode = PathElement.groupElement("subpixelMode"); + public static final PathElement PATH$sadAdjustMode = PathElement.groupElement("sadAdjustMode"); + public static final PathElement PATH$searchPathType = PathElement.groupElement("searchPathType"); + + public static final OfInt LAYOUT$mbBlockType = (OfInt) LAYOUT.select(PATH$mbBlockType); + public static final OfInt LAYOUT$subpixelMode = (OfInt) LAYOUT.select(PATH$subpixelMode); + public static final OfInt LAYOUT$sadAdjustMode = (OfInt) LAYOUT.select(PATH$sadAdjustMode); + public static final OfInt LAYOUT$searchPathType = (OfInt) LAYOUT.select(PATH$searchPathType); + + public static final long SIZE$mbBlockType = LAYOUT$mbBlockType.byteSize(); + public static final long SIZE$subpixelMode = LAYOUT$subpixelMode.byteSize(); + public static final long SIZE$sadAdjustMode = LAYOUT$sadAdjustMode.byteSize(); + public static final long SIZE$searchPathType = LAYOUT$searchPathType.byteSize(); + + public static final long OFFSET$mbBlockType = LAYOUT.byteOffset(PATH$mbBlockType); + public static final long OFFSET$subpixelMode = LAYOUT.byteOffset(PATH$subpixelMode); + public static final long OFFSET$sadAdjustMode = LAYOUT.byteOffset(PATH$sadAdjustMode); + public static final long OFFSET$searchPathType = LAYOUT.byteOffset(PATH$searchPathType); +} diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr$Ptr$Iter.class new file mode 100644 index 0000000..a89c711 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr$Ptr.class b/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr$Ptr.class new file mode 100644 index 0000000..43f123c Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr.class b/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr.class new file mode 100644 index 0000000..0a84391 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr.java b/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr.java new file mode 100644 index 0000000..c0cd33f --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLMutableDispatchArgKhr.java @@ -0,0 +1,231 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_mutable_dispatch_arg_khr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_mutable_dispatch_arg_khr { +/// cl_uint argIndex; // @link substring="argIndex" target="#argIndex" +/// size_t argSize; // @link substring="argSize" target="#argSize" +/// void const* argValue; // @link substring="argValue" target="#argValue" +/// } cl_mutable_dispatch_arg_khr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_mutable_dispatch_arg_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLMutableDispatchArgKhr(@NotNull MemorySegment segment) implements ICLMutableDispatchArgKhr { + /// Represents a pointer to / an array of cl_mutable_dispatch_arg_khr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLMutableDispatchArgKhr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLMutableDispatchArgKhr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLMutableDispatchArgKhr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLMutableDispatchArgKhr, Iterable { + public long size() { + return segment.byteSize() / CLMutableDispatchArgKhr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLMutableDispatchArgKhr at(long index) { + return new CLMutableDispatchArgKhr(segment.asSlice(index * CLMutableDispatchArgKhr.BYTES, CLMutableDispatchArgKhr.BYTES)); + } + + public CLMutableDispatchArgKhr.Ptr at(long index, @NotNull Consumer<@NotNull CLMutableDispatchArgKhr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLMutableDispatchArgKhr value) { + MemorySegment s = segment.asSlice(index * CLMutableDispatchArgKhr.BYTES, CLMutableDispatchArgKhr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLMutableDispatchArgKhr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLMutableDispatchArgKhr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLMutableDispatchArgKhr.BYTES, + (end - start) * CLMutableDispatchArgKhr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLMutableDispatchArgKhr.BYTES)); + } + + public CLMutableDispatchArgKhr[] toArray() { + CLMutableDispatchArgKhr[] ret = new CLMutableDispatchArgKhr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLMutableDispatchArgKhr.BYTES; + } + + @Override + public CLMutableDispatchArgKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLMutableDispatchArgKhr ret = new CLMutableDispatchArgKhr(segment.asSlice(0, CLMutableDispatchArgKhr.BYTES)); + segment = segment.asSlice(CLMutableDispatchArgKhr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLMutableDispatchArgKhr allocate(Arena arena) { + return new CLMutableDispatchArgKhr(arena.allocate(LAYOUT)); + } + + public static CLMutableDispatchArgKhr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLMutableDispatchArgKhr.Ptr(segment); + } + + public static CLMutableDispatchArgKhr clone(Arena arena, CLMutableDispatchArgKhr src) { + CLMutableDispatchArgKhr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_uint") @Unsigned int argIndex() { + return segment.get(LAYOUT$argIndex, OFFSET$argIndex); + } + + public CLMutableDispatchArgKhr argIndex(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$argIndex, OFFSET$argIndex, value); + return this; + } + + public @Unsigned long argSize() { + return NativeLayout.readCSizeT(segment, OFFSET$argSize); + } + + public CLMutableDispatchArgKhr argSize(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$argSize, value); + return this; + } + + public @Pointer(comment="void*") @NotNull MemorySegment argValue() { + return segment.get(LAYOUT$argValue, OFFSET$argValue); + } + + public CLMutableDispatchArgKhr argValue(@Pointer(comment="void*") @NotNull MemorySegment value) { + segment.set(LAYOUT$argValue, OFFSET$argValue, value); + return this; + } + + public CLMutableDispatchArgKhr argValue(@Nullable IPointer pointer) { + argValue(pointer != null ? pointer.segment() : MemorySegment.NULL); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("argIndex"), + NativeLayout.C_SIZE_T.withName("argSize"), + ValueLayout.ADDRESS.withName("argValue") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$argIndex = PathElement.groupElement("argIndex"); + public static final PathElement PATH$argSize = PathElement.groupElement("argSize"); + public static final PathElement PATH$argValue = PathElement.groupElement("argValue"); + + public static final OfInt LAYOUT$argIndex = (OfInt) LAYOUT.select(PATH$argIndex); + public static final AddressLayout LAYOUT$argValue = (AddressLayout) LAYOUT.select(PATH$argValue); + + public static final long SIZE$argIndex = LAYOUT$argIndex.byteSize(); + public static final long SIZE$argSize = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$argValue = LAYOUT$argValue.byteSize(); + + public static final long OFFSET$argIndex = LAYOUT.byteOffset(PATH$argIndex); + public static final long OFFSET$argSize = LAYOUT.byteOffset(PATH$argSize); + public static final long OFFSET$argValue = LAYOUT.byteOffset(PATH$argValue); +} diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr$Ptr$Iter.class new file mode 100644 index 0000000..f067f44 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr$Ptr.class b/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr$Ptr.class new file mode 100644 index 0000000..3cc6214 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr.class b/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr.class new file mode 100644 index 0000000..7ec3540 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr.java b/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr.java new file mode 100644 index 0000000..8f6b19e --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLMutableDispatchConfigKhr.java @@ -0,0 +1,471 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_mutable_dispatch_config_khr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_mutable_dispatch_config_khr { +/// cl_mutable_command_khr command; // @link substring="CLMutableCommandKhr" target="CLMutableCommandKhr" @link substring="command" target="#command" +/// cl_uint numArgs; // @link substring="numArgs" target="#numArgs" +/// cl_uint numSvmArgs; // @link substring="numSvmArgs" target="#numSvmArgs" +/// cl_uint numExecInfos; // @link substring="numExecInfos" target="#numExecInfos" +/// cl_uint workDim; // @link substring="workDim" target="#workDim" +/// cl_mutable_dispatch_arg_khr const* argList; // @link substring="CLMutableDispatchArgKhr" target="CLMutableDispatchArgKhr" @link substring="argList" target="#argList" +/// cl_mutable_dispatch_arg_khr const* argSvmList; // @link substring="CLMutableDispatchArgKhr" target="CLMutableDispatchArgKhr" @link substring="argSvmList" target="#argSvmList" +/// cl_mutable_dispatch_exec_info_khr const* execInfoList; // @link substring="CLMutableDispatchExecInfoKhr" target="CLMutableDispatchExecInfoKhr" @link substring="execInfoList" target="#execInfoList" +/// size_t const* globalWorkOffset; // @link substring="globalWorkOffset" target="#globalWorkOffset" +/// size_t const* globalWorkSize; // @link substring="globalWorkSize" target="#globalWorkSize" +/// size_t const* localWorkSize; // @link substring="localWorkSize" target="#localWorkSize" +/// } cl_mutable_dispatch_config_khr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_mutable_dispatch_config_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLMutableDispatchConfigKhr(@NotNull MemorySegment segment) implements ICLMutableDispatchConfigKhr { + /// Represents a pointer to / an array of cl_mutable_dispatch_config_khr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLMutableDispatchConfigKhr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLMutableDispatchConfigKhr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLMutableDispatchConfigKhr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLMutableDispatchConfigKhr, Iterable { + public long size() { + return segment.byteSize() / CLMutableDispatchConfigKhr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLMutableDispatchConfigKhr at(long index) { + return new CLMutableDispatchConfigKhr(segment.asSlice(index * CLMutableDispatchConfigKhr.BYTES, CLMutableDispatchConfigKhr.BYTES)); + } + + public CLMutableDispatchConfigKhr.Ptr at(long index, @NotNull Consumer<@NotNull CLMutableDispatchConfigKhr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLMutableDispatchConfigKhr value) { + MemorySegment s = segment.asSlice(index * CLMutableDispatchConfigKhr.BYTES, CLMutableDispatchConfigKhr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLMutableDispatchConfigKhr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLMutableDispatchConfigKhr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLMutableDispatchConfigKhr.BYTES, + (end - start) * CLMutableDispatchConfigKhr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLMutableDispatchConfigKhr.BYTES)); + } + + public CLMutableDispatchConfigKhr[] toArray() { + CLMutableDispatchConfigKhr[] ret = new CLMutableDispatchConfigKhr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLMutableDispatchConfigKhr.BYTES; + } + + @Override + public CLMutableDispatchConfigKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLMutableDispatchConfigKhr ret = new CLMutableDispatchConfigKhr(segment.asSlice(0, CLMutableDispatchConfigKhr.BYTES)); + segment = segment.asSlice(CLMutableDispatchConfigKhr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLMutableDispatchConfigKhr allocate(Arena arena) { + return new CLMutableDispatchConfigKhr(arena.allocate(LAYOUT)); + } + + public static CLMutableDispatchConfigKhr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLMutableDispatchConfigKhr.Ptr(segment); + } + + public static CLMutableDispatchConfigKhr clone(Arena arena, CLMutableDispatchConfigKhr src) { + CLMutableDispatchConfigKhr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @Nullable CLMutableCommandKhr command() { + MemorySegment s = segment.asSlice(OFFSET$command, SIZE$command); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMutableCommandKhr(s); + } + + public CLMutableDispatchConfigKhr command(@Nullable CLMutableCommandKhr value) { + segment.set(LAYOUT$command, OFFSET$command, value != null ? value.segment() : MemorySegment.NULL); + return this; + } + + public @NativeType("cl_uint") @Unsigned int numArgs() { + return segment.get(LAYOUT$numArgs, OFFSET$numArgs); + } + + public CLMutableDispatchConfigKhr numArgs(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$numArgs, OFFSET$numArgs, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int numSvmArgs() { + return segment.get(LAYOUT$numSvmArgs, OFFSET$numSvmArgs); + } + + public CLMutableDispatchConfigKhr numSvmArgs(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$numSvmArgs, OFFSET$numSvmArgs, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int numExecInfos() { + return segment.get(LAYOUT$numExecInfos, OFFSET$numExecInfos); + } + + public CLMutableDispatchConfigKhr numExecInfos(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$numExecInfos, OFFSET$numExecInfos, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int workDim() { + return segment.get(LAYOUT$workDim, OFFSET$workDim); + } + + public CLMutableDispatchConfigKhr workDim(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$workDim, OFFSET$workDim, value); + return this; + } + + public CLMutableDispatchConfigKhr argList(@Nullable ICLMutableDispatchArgKhr value) { + MemorySegment s = value == null ? MemorySegment.NULL : value.segment(); + argListRaw(s); + return this; + } + + @Unsafe public @Nullable CLMutableDispatchArgKhr.Ptr argList(int assumedCount) { + MemorySegment s = argListRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + + s = s.reinterpret(assumedCount * CLMutableDispatchArgKhr.BYTES); + return new CLMutableDispatchArgKhr.Ptr(s); + } + + public @Nullable CLMutableDispatchArgKhr argList() { + MemorySegment s = argListRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMutableDispatchArgKhr(s); + } + + public @Pointer(target=CLMutableDispatchArgKhr.class) @NotNull MemorySegment argListRaw() { + return segment.get(LAYOUT$argList, OFFSET$argList); + } + + public void argListRaw(@Pointer(target=CLMutableDispatchArgKhr.class) @NotNull MemorySegment value) { + segment.set(LAYOUT$argList, OFFSET$argList, value); + } + + public CLMutableDispatchConfigKhr argSvmList(@Nullable ICLMutableDispatchArgKhr value) { + MemorySegment s = value == null ? MemorySegment.NULL : value.segment(); + argSvmListRaw(s); + return this; + } + + @Unsafe public @Nullable CLMutableDispatchArgKhr.Ptr argSvmList(int assumedCount) { + MemorySegment s = argSvmListRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + + s = s.reinterpret(assumedCount * CLMutableDispatchArgKhr.BYTES); + return new CLMutableDispatchArgKhr.Ptr(s); + } + + public @Nullable CLMutableDispatchArgKhr argSvmList() { + MemorySegment s = argSvmListRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMutableDispatchArgKhr(s); + } + + public @Pointer(target=CLMutableDispatchArgKhr.class) @NotNull MemorySegment argSvmListRaw() { + return segment.get(LAYOUT$argSvmList, OFFSET$argSvmList); + } + + public void argSvmListRaw(@Pointer(target=CLMutableDispatchArgKhr.class) @NotNull MemorySegment value) { + segment.set(LAYOUT$argSvmList, OFFSET$argSvmList, value); + } + + public CLMutableDispatchConfigKhr execInfoList(@Nullable ICLMutableDispatchExecInfoKhr value) { + MemorySegment s = value == null ? MemorySegment.NULL : value.segment(); + execInfoListRaw(s); + return this; + } + + @Unsafe public @Nullable CLMutableDispatchExecInfoKhr.Ptr execInfoList(int assumedCount) { + MemorySegment s = execInfoListRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + + s = s.reinterpret(assumedCount * CLMutableDispatchExecInfoKhr.BYTES); + return new CLMutableDispatchExecInfoKhr.Ptr(s); + } + + public @Nullable CLMutableDispatchExecInfoKhr execInfoList() { + MemorySegment s = execInfoListRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMutableDispatchExecInfoKhr(s); + } + + public @Pointer(target=CLMutableDispatchExecInfoKhr.class) @NotNull MemorySegment execInfoListRaw() { + return segment.get(LAYOUT$execInfoList, OFFSET$execInfoList); + } + + public void execInfoListRaw(@Pointer(target=CLMutableDispatchExecInfoKhr.class) @NotNull MemorySegment value) { + segment.set(LAYOUT$execInfoList, OFFSET$execInfoList, value); + } + + /// Note: the returned {@link PointerPtr} does not have correct + /// {@link PointerPtr#size} property. It's up to user to track the size of the buffer, + /// and use {@link PointerPtr#reinterpret} to set the size before actually reading from or + /// writing to the buffer. + public @Nullable PointerPtr globalWorkOffset() { + MemorySegment s = globalWorkOffsetRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new PointerPtr(s); + } + + public CLMutableDispatchConfigKhr globalWorkOffset(@Nullable PointerPtr value) { + MemorySegment s = value == null ? MemorySegment.NULL : value.segment(); + globalWorkOffsetRaw(s); + return this; + } + + public @Pointer(comment="size_t*") @NotNull MemorySegment globalWorkOffsetRaw() { + return segment.get(LAYOUT$globalWorkOffset, OFFSET$globalWorkOffset); + } + + public void globalWorkOffsetRaw(@Pointer(comment="size_t*") @NotNull MemorySegment value) { + segment.set(LAYOUT$globalWorkOffset, OFFSET$globalWorkOffset, value); + } + + /// Note: the returned {@link PointerPtr} does not have correct + /// {@link PointerPtr#size} property. It's up to user to track the size of the buffer, + /// and use {@link PointerPtr#reinterpret} to set the size before actually reading from or + /// writing to the buffer. + public @Nullable PointerPtr globalWorkSize() { + MemorySegment s = globalWorkSizeRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new PointerPtr(s); + } + + public CLMutableDispatchConfigKhr globalWorkSize(@Nullable PointerPtr value) { + MemorySegment s = value == null ? MemorySegment.NULL : value.segment(); + globalWorkSizeRaw(s); + return this; + } + + public @Pointer(comment="size_t*") @NotNull MemorySegment globalWorkSizeRaw() { + return segment.get(LAYOUT$globalWorkSize, OFFSET$globalWorkSize); + } + + public void globalWorkSizeRaw(@Pointer(comment="size_t*") @NotNull MemorySegment value) { + segment.set(LAYOUT$globalWorkSize, OFFSET$globalWorkSize, value); + } + + /// Note: the returned {@link PointerPtr} does not have correct + /// {@link PointerPtr#size} property. It's up to user to track the size of the buffer, + /// and use {@link PointerPtr#reinterpret} to set the size before actually reading from or + /// writing to the buffer. + public @Nullable PointerPtr localWorkSize() { + MemorySegment s = localWorkSizeRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new PointerPtr(s); + } + + public CLMutableDispatchConfigKhr localWorkSize(@Nullable PointerPtr value) { + MemorySegment s = value == null ? MemorySegment.NULL : value.segment(); + localWorkSizeRaw(s); + return this; + } + + public @Pointer(comment="size_t*") @NotNull MemorySegment localWorkSizeRaw() { + return segment.get(LAYOUT$localWorkSize, OFFSET$localWorkSize); + } + + public void localWorkSizeRaw(@Pointer(comment="size_t*") @NotNull MemorySegment value) { + segment.set(LAYOUT$localWorkSize, OFFSET$localWorkSize, value); + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.ADDRESS.withName("command"), + ValueLayout.JAVA_INT.withName("numArgs"), + ValueLayout.JAVA_INT.withName("numSvmArgs"), + ValueLayout.JAVA_INT.withName("numExecInfos"), + ValueLayout.JAVA_INT.withName("workDim"), + ValueLayout.ADDRESS.withTargetLayout(CLMutableDispatchArgKhr.LAYOUT).withName("argList"), + ValueLayout.ADDRESS.withTargetLayout(CLMutableDispatchArgKhr.LAYOUT).withName("argSvmList"), + ValueLayout.ADDRESS.withTargetLayout(CLMutableDispatchExecInfoKhr.LAYOUT).withName("execInfoList"), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T).withName("globalWorkOffset"), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T).withName("globalWorkSize"), + ValueLayout.ADDRESS.withTargetLayout(NativeLayout.C_SIZE_T).withName("localWorkSize") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$command = PathElement.groupElement("command"); + public static final PathElement PATH$numArgs = PathElement.groupElement("numArgs"); + public static final PathElement PATH$numSvmArgs = PathElement.groupElement("numSvmArgs"); + public static final PathElement PATH$numExecInfos = PathElement.groupElement("numExecInfos"); + public static final PathElement PATH$workDim = PathElement.groupElement("workDim"); + public static final PathElement PATH$argList = PathElement.groupElement("argList"); + public static final PathElement PATH$argSvmList = PathElement.groupElement("argSvmList"); + public static final PathElement PATH$execInfoList = PathElement.groupElement("execInfoList"); + public static final PathElement PATH$globalWorkOffset = PathElement.groupElement("globalWorkOffset"); + public static final PathElement PATH$globalWorkSize = PathElement.groupElement("globalWorkSize"); + public static final PathElement PATH$localWorkSize = PathElement.groupElement("localWorkSize"); + + public static final AddressLayout LAYOUT$command = (AddressLayout) LAYOUT.select(PATH$command); + public static final OfInt LAYOUT$numArgs = (OfInt) LAYOUT.select(PATH$numArgs); + public static final OfInt LAYOUT$numSvmArgs = (OfInt) LAYOUT.select(PATH$numSvmArgs); + public static final OfInt LAYOUT$numExecInfos = (OfInt) LAYOUT.select(PATH$numExecInfos); + public static final OfInt LAYOUT$workDim = (OfInt) LAYOUT.select(PATH$workDim); + public static final AddressLayout LAYOUT$argList = (AddressLayout) LAYOUT.select(PATH$argList); + public static final AddressLayout LAYOUT$argSvmList = (AddressLayout) LAYOUT.select(PATH$argSvmList); + public static final AddressLayout LAYOUT$execInfoList = (AddressLayout) LAYOUT.select(PATH$execInfoList); + public static final AddressLayout LAYOUT$globalWorkOffset = (AddressLayout) LAYOUT.select(PATH$globalWorkOffset); + public static final AddressLayout LAYOUT$globalWorkSize = (AddressLayout) LAYOUT.select(PATH$globalWorkSize); + public static final AddressLayout LAYOUT$localWorkSize = (AddressLayout) LAYOUT.select(PATH$localWorkSize); + + public static final long SIZE$command = LAYOUT$command.byteSize(); + public static final long SIZE$numArgs = LAYOUT$numArgs.byteSize(); + public static final long SIZE$numSvmArgs = LAYOUT$numSvmArgs.byteSize(); + public static final long SIZE$numExecInfos = LAYOUT$numExecInfos.byteSize(); + public static final long SIZE$workDim = LAYOUT$workDim.byteSize(); + public static final long SIZE$argList = LAYOUT$argList.byteSize(); + public static final long SIZE$argSvmList = LAYOUT$argSvmList.byteSize(); + public static final long SIZE$execInfoList = LAYOUT$execInfoList.byteSize(); + public static final long SIZE$globalWorkOffset = LAYOUT$globalWorkOffset.byteSize(); + public static final long SIZE$globalWorkSize = LAYOUT$globalWorkSize.byteSize(); + public static final long SIZE$localWorkSize = LAYOUT$localWorkSize.byteSize(); + + public static final long OFFSET$command = LAYOUT.byteOffset(PATH$command); + public static final long OFFSET$numArgs = LAYOUT.byteOffset(PATH$numArgs); + public static final long OFFSET$numSvmArgs = LAYOUT.byteOffset(PATH$numSvmArgs); + public static final long OFFSET$numExecInfos = LAYOUT.byteOffset(PATH$numExecInfos); + public static final long OFFSET$workDim = LAYOUT.byteOffset(PATH$workDim); + public static final long OFFSET$argList = LAYOUT.byteOffset(PATH$argList); + public static final long OFFSET$argSvmList = LAYOUT.byteOffset(PATH$argSvmList); + public static final long OFFSET$execInfoList = LAYOUT.byteOffset(PATH$execInfoList); + public static final long OFFSET$globalWorkOffset = LAYOUT.byteOffset(PATH$globalWorkOffset); + public static final long OFFSET$globalWorkSize = LAYOUT.byteOffset(PATH$globalWorkSize); + public static final long OFFSET$localWorkSize = LAYOUT.byteOffset(PATH$localWorkSize); +} diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr$Ptr$Iter.class new file mode 100644 index 0000000..69175af Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr$Ptr.class b/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr$Ptr.class new file mode 100644 index 0000000..68d1206 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr.class b/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr.class new file mode 100644 index 0000000..42740dc Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr.class differ diff --git a/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr.java b/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr.java new file mode 100644 index 0000000..fdea2dc --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLMutableDispatchExecInfoKhr.java @@ -0,0 +1,231 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_mutable_dispatch_exec_info_khr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_mutable_dispatch_exec_info_khr { +/// cl_uint paramName; // @link substring="paramName" target="#paramName" +/// size_t paramValueSize; // @link substring="paramValueSize" target="#paramValueSize" +/// void const* paramValue; // @link substring="paramValue" target="#paramValue" +/// } cl_mutable_dispatch_exec_info_khr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_mutable_dispatch_exec_info_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLMutableDispatchExecInfoKhr(@NotNull MemorySegment segment) implements ICLMutableDispatchExecInfoKhr { + /// Represents a pointer to / an array of cl_mutable_dispatch_exec_info_khr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLMutableDispatchExecInfoKhr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLMutableDispatchExecInfoKhr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLMutableDispatchExecInfoKhr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLMutableDispatchExecInfoKhr, Iterable { + public long size() { + return segment.byteSize() / CLMutableDispatchExecInfoKhr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLMutableDispatchExecInfoKhr at(long index) { + return new CLMutableDispatchExecInfoKhr(segment.asSlice(index * CLMutableDispatchExecInfoKhr.BYTES, CLMutableDispatchExecInfoKhr.BYTES)); + } + + public CLMutableDispatchExecInfoKhr.Ptr at(long index, @NotNull Consumer<@NotNull CLMutableDispatchExecInfoKhr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLMutableDispatchExecInfoKhr value) { + MemorySegment s = segment.asSlice(index * CLMutableDispatchExecInfoKhr.BYTES, CLMutableDispatchExecInfoKhr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLMutableDispatchExecInfoKhr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLMutableDispatchExecInfoKhr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLMutableDispatchExecInfoKhr.BYTES, + (end - start) * CLMutableDispatchExecInfoKhr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLMutableDispatchExecInfoKhr.BYTES)); + } + + public CLMutableDispatchExecInfoKhr[] toArray() { + CLMutableDispatchExecInfoKhr[] ret = new CLMutableDispatchExecInfoKhr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLMutableDispatchExecInfoKhr.BYTES; + } + + @Override + public CLMutableDispatchExecInfoKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLMutableDispatchExecInfoKhr ret = new CLMutableDispatchExecInfoKhr(segment.asSlice(0, CLMutableDispatchExecInfoKhr.BYTES)); + segment = segment.asSlice(CLMutableDispatchExecInfoKhr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLMutableDispatchExecInfoKhr allocate(Arena arena) { + return new CLMutableDispatchExecInfoKhr(arena.allocate(LAYOUT)); + } + + public static CLMutableDispatchExecInfoKhr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLMutableDispatchExecInfoKhr.Ptr(segment); + } + + public static CLMutableDispatchExecInfoKhr clone(Arena arena, CLMutableDispatchExecInfoKhr src) { + CLMutableDispatchExecInfoKhr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_uint") @Unsigned int paramName() { + return segment.get(LAYOUT$paramName, OFFSET$paramName); + } + + public CLMutableDispatchExecInfoKhr paramName(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$paramName, OFFSET$paramName, value); + return this; + } + + public @Unsigned long paramValueSize() { + return NativeLayout.readCSizeT(segment, OFFSET$paramValueSize); + } + + public CLMutableDispatchExecInfoKhr paramValueSize(@Unsigned long value) { + NativeLayout.writeCSizeT(segment, OFFSET$paramValueSize, value); + return this; + } + + public @Pointer(comment="void*") @NotNull MemorySegment paramValue() { + return segment.get(LAYOUT$paramValue, OFFSET$paramValue); + } + + public CLMutableDispatchExecInfoKhr paramValue(@Pointer(comment="void*") @NotNull MemorySegment value) { + segment.set(LAYOUT$paramValue, OFFSET$paramValue, value); + return this; + } + + public CLMutableDispatchExecInfoKhr paramValue(@Nullable IPointer pointer) { + paramValue(pointer != null ? pointer.segment() : MemorySegment.NULL); + return this; + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("paramName"), + NativeLayout.C_SIZE_T.withName("paramValueSize"), + ValueLayout.ADDRESS.withName("paramValue") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$paramName = PathElement.groupElement("paramName"); + public static final PathElement PATH$paramValueSize = PathElement.groupElement("paramValueSize"); + public static final PathElement PATH$paramValue = PathElement.groupElement("paramValue"); + + public static final OfInt LAYOUT$paramName = (OfInt) LAYOUT.select(PATH$paramName); + public static final AddressLayout LAYOUT$paramValue = (AddressLayout) LAYOUT.select(PATH$paramValue); + + public static final long SIZE$paramName = LAYOUT$paramName.byteSize(); + public static final long SIZE$paramValueSize = NativeLayout.C_SIZE_T.byteSize(); + public static final long SIZE$paramValue = LAYOUT$paramValue.byteSize(); + + public static final long OFFSET$paramName = LAYOUT.byteOffset(PATH$paramName); + public static final long OFFSET$paramValueSize = LAYOUT.byteOffset(PATH$paramValueSize); + public static final long OFFSET$paramValue = LAYOUT.byteOffset(PATH$paramValue); +} diff --git a/src/club/doki7/opencl/datatype/CLNameVersion$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLNameVersion$Ptr$Iter.class new file mode 100644 index 0000000..f5cbeca Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLNameVersion$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLNameVersion$Ptr.class b/src/club/doki7/opencl/datatype/CLNameVersion$Ptr.class new file mode 100644 index 0000000..66022d2 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLNameVersion$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLNameVersion.class b/src/club/doki7/opencl/datatype/CLNameVersion.class new file mode 100644 index 0000000..d56486b Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLNameVersion.class differ diff --git a/src/club/doki7/opencl/datatype/CLNameVersion.java b/src/club/doki7/opencl/datatype/CLNameVersion.java new file mode 100644 index 0000000..1300f86 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLNameVersion.java @@ -0,0 +1,223 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_name_version structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_name_version { +/// cl_version version; // @link substring="version" target="#version" +/// char[CL_NAME_VERSION_MAX_NAME_SIZE] name; // @link substring="name" target="#name" +/// } cl_name_version; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_name_version +@ValueBasedCandidate +@UnsafeConstructor +public record CLNameVersion(@NotNull MemorySegment segment) implements ICLNameVersion { + /// Represents a pointer to / an array of cl_name_version structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLNameVersion}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLNameVersion to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLNameVersion.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLNameVersion, Iterable { + public long size() { + return segment.byteSize() / CLNameVersion.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLNameVersion at(long index) { + return new CLNameVersion(segment.asSlice(index * CLNameVersion.BYTES, CLNameVersion.BYTES)); + } + + public CLNameVersion.Ptr at(long index, @NotNull Consumer<@NotNull CLNameVersion> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLNameVersion value) { + MemorySegment s = segment.asSlice(index * CLNameVersion.BYTES, CLNameVersion.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLNameVersion.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLNameVersion.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLNameVersion.BYTES, + (end - start) * CLNameVersion.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLNameVersion.BYTES)); + } + + public CLNameVersion[] toArray() { + CLNameVersion[] ret = new CLNameVersion[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLNameVersion.BYTES; + } + + @Override + public CLNameVersion next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLNameVersion ret = new CLNameVersion(segment.asSlice(0, CLNameVersion.BYTES)); + segment = segment.asSlice(CLNameVersion.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLNameVersion allocate(Arena arena) { + return new CLNameVersion(arena.allocate(LAYOUT)); + } + + public static CLNameVersion.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLNameVersion.Ptr(segment); + } + + public static CLNameVersion clone(Arena arena, CLNameVersion src) { + CLNameVersion ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_version") @Unsigned int version() { + return segment.get(LAYOUT$version, OFFSET$version); + } + + public CLNameVersion version(@NativeType("cl_version") @Unsigned int value) { + segment.set(LAYOUT$version, OFFSET$version, value); + return this; + } + + public BytePtr name() { + return new BytePtr(nameRaw()); + } + + public CLNameVersion name(@NotNull Consumer consumer) { + BytePtr ptr = name(); + consumer.accept(ptr); + return this; + } + + public CLNameVersion name(BytePtr value) { + MemorySegment s = nameRaw(); + s.copyFrom(value.segment()); + return this; + } + + public @NotNull MemorySegment nameRaw() { + return segment.asSlice(OFFSET$name, SIZE$name); + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("version"), + MemoryLayout.sequenceLayout(NAME_VERSION_MAX_NAME_SIZE, ValueLayout.JAVA_BYTE).withName("name") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$version = PathElement.groupElement("version"); + public static final PathElement PATH$name = PathElement.groupElement("name"); + + public static final OfInt LAYOUT$version = (OfInt) LAYOUT.select(PATH$version); + public static final SequenceLayout LAYOUT$name = (SequenceLayout) LAYOUT.select(PATH$name); + + public static final long SIZE$version = LAYOUT$version.byteSize(); + public static final long SIZE$name = LAYOUT$name.byteSize(); + + public static final long OFFSET$version = LAYOUT.byteOffset(PATH$version); + public static final long OFFSET$name = LAYOUT.byteOffset(PATH$name); +} diff --git a/src/club/doki7/opencl/datatype/CLNameVersionKhr$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLNameVersionKhr$Ptr$Iter.class new file mode 100644 index 0000000..4725a39 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLNameVersionKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLNameVersionKhr$Ptr.class b/src/club/doki7/opencl/datatype/CLNameVersionKhr$Ptr.class new file mode 100644 index 0000000..6c04556 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLNameVersionKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLNameVersionKhr.class b/src/club/doki7/opencl/datatype/CLNameVersionKhr.class new file mode 100644 index 0000000..044bad5 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLNameVersionKhr.class differ diff --git a/src/club/doki7/opencl/datatype/CLNameVersionKhr.java b/src/club/doki7/opencl/datatype/CLNameVersionKhr.java new file mode 100644 index 0000000..3d3b7f9 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLNameVersionKhr.java @@ -0,0 +1,223 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_name_version_khr structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_name_version_khr { +/// cl_version_khr version; // @link substring="version" target="#version" +/// char[CL_NAME_VERSION_MAX_NAME_SIZE_KHR] name; // @link substring="name" target="#name" +/// } cl_name_version_khr; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_name_version_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLNameVersionKhr(@NotNull MemorySegment segment) implements ICLNameVersionKhr { + /// Represents a pointer to / an array of cl_name_version_khr structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLNameVersionKhr}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLNameVersionKhr to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLNameVersionKhr.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLNameVersionKhr, Iterable { + public long size() { + return segment.byteSize() / CLNameVersionKhr.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLNameVersionKhr at(long index) { + return new CLNameVersionKhr(segment.asSlice(index * CLNameVersionKhr.BYTES, CLNameVersionKhr.BYTES)); + } + + public CLNameVersionKhr.Ptr at(long index, @NotNull Consumer<@NotNull CLNameVersionKhr> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLNameVersionKhr value) { + MemorySegment s = segment.asSlice(index * CLNameVersionKhr.BYTES, CLNameVersionKhr.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLNameVersionKhr.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLNameVersionKhr.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLNameVersionKhr.BYTES, + (end - start) * CLNameVersionKhr.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLNameVersionKhr.BYTES)); + } + + public CLNameVersionKhr[] toArray() { + CLNameVersionKhr[] ret = new CLNameVersionKhr[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLNameVersionKhr.BYTES; + } + + @Override + public CLNameVersionKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLNameVersionKhr ret = new CLNameVersionKhr(segment.asSlice(0, CLNameVersionKhr.BYTES)); + segment = segment.asSlice(CLNameVersionKhr.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLNameVersionKhr allocate(Arena arena) { + return new CLNameVersionKhr(arena.allocate(LAYOUT)); + } + + public static CLNameVersionKhr.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLNameVersionKhr.Ptr(segment); + } + + public static CLNameVersionKhr clone(Arena arena, CLNameVersionKhr src) { + CLNameVersionKhr ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_version_khr") @Unsigned int version() { + return segment.get(LAYOUT$version, OFFSET$version); + } + + public CLNameVersionKhr version(@NativeType("cl_version_khr") @Unsigned int value) { + segment.set(LAYOUT$version, OFFSET$version, value); + return this; + } + + public BytePtr name() { + return new BytePtr(nameRaw()); + } + + public CLNameVersionKhr name(@NotNull Consumer consumer) { + BytePtr ptr = name(); + consumer.accept(ptr); + return this; + } + + public CLNameVersionKhr name(BytePtr value) { + MemorySegment s = nameRaw(); + s.copyFrom(value.segment()); + return this; + } + + public @NotNull MemorySegment nameRaw() { + return segment.asSlice(OFFSET$name, SIZE$name); + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("version"), + MemoryLayout.sequenceLayout(NAME_VERSION_MAX_NAME_SIZE_KHR, ValueLayout.JAVA_BYTE).withName("name") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$version = PathElement.groupElement("version"); + public static final PathElement PATH$name = PathElement.groupElement("name"); + + public static final OfInt LAYOUT$version = (OfInt) LAYOUT.select(PATH$version); + public static final SequenceLayout LAYOUT$name = (SequenceLayout) LAYOUT.select(PATH$name); + + public static final long SIZE$version = LAYOUT$version.byteSize(); + public static final long SIZE$name = LAYOUT$name.byteSize(); + + public static final long OFFSET$version = LAYOUT.byteOffset(PATH$version); + public static final long OFFSET$name = LAYOUT.byteOffset(PATH$name); +} diff --git a/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel$Ptr$Iter.class b/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel$Ptr$Iter.class new file mode 100644 index 0000000..78d1423 Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel$Ptr.class b/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel$Ptr.class new file mode 100644 index 0000000..e52b90f Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel.class b/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel.class new file mode 100644 index 0000000..ada83ce Binary files /dev/null and b/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel.class differ diff --git a/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel.java b/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel.java new file mode 100644 index 0000000..e693fc4 --- /dev/null +++ b/src/club/doki7/opencl/datatype/CLQueueFamilyPropertiesIntel.java @@ -0,0 +1,253 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a cl_queue_family_properties_intel structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct cl_queue_family_properties_intel { +/// cl_command_queue_properties properties; // @link substring="properties" target="#properties" +/// cl_command_queue_capabilities_intel capabilities; // @link substring="capabilities" target="#capabilities" +/// cl_uint count; // @link substring="count" target="#count" +/// char[CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL] name; // @link substring="name" target="#name" +/// } cl_queue_family_properties_intel; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_queue_family_properties_intel +@ValueBasedCandidate +@UnsafeConstructor +public record CLQueueFamilyPropertiesIntel(@NotNull MemorySegment segment) implements ICLQueueFamilyPropertiesIntel { + /// Represents a pointer to / an array of cl_queue_family_properties_intel structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link CLQueueFamilyPropertiesIntel}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// ICLQueueFamilyPropertiesIntel to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code CLQueueFamilyPropertiesIntel.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements ICLQueueFamilyPropertiesIntel, Iterable { + public long size() { + return segment.byteSize() / CLQueueFamilyPropertiesIntel.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull CLQueueFamilyPropertiesIntel at(long index) { + return new CLQueueFamilyPropertiesIntel(segment.asSlice(index * CLQueueFamilyPropertiesIntel.BYTES, CLQueueFamilyPropertiesIntel.BYTES)); + } + + public CLQueueFamilyPropertiesIntel.Ptr at(long index, @NotNull Consumer<@NotNull CLQueueFamilyPropertiesIntel> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull CLQueueFamilyPropertiesIntel value) { + MemorySegment s = segment.asSlice(index * CLQueueFamilyPropertiesIntel.BYTES, CLQueueFamilyPropertiesIntel.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * CLQueueFamilyPropertiesIntel.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * CLQueueFamilyPropertiesIntel.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * CLQueueFamilyPropertiesIntel.BYTES, + (end - start) * CLQueueFamilyPropertiesIntel.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * CLQueueFamilyPropertiesIntel.BYTES)); + } + + public CLQueueFamilyPropertiesIntel[] toArray() { + CLQueueFamilyPropertiesIntel[] ret = new CLQueueFamilyPropertiesIntel[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= CLQueueFamilyPropertiesIntel.BYTES; + } + + @Override + public CLQueueFamilyPropertiesIntel next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + CLQueueFamilyPropertiesIntel ret = new CLQueueFamilyPropertiesIntel(segment.asSlice(0, CLQueueFamilyPropertiesIntel.BYTES)); + segment = segment.asSlice(CLQueueFamilyPropertiesIntel.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static CLQueueFamilyPropertiesIntel allocate(Arena arena) { + return new CLQueueFamilyPropertiesIntel(arena.allocate(LAYOUT)); + } + + public static CLQueueFamilyPropertiesIntel.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new CLQueueFamilyPropertiesIntel.Ptr(segment); + } + + public static CLQueueFamilyPropertiesIntel clone(Arena arena, CLQueueFamilyPropertiesIntel src) { + CLQueueFamilyPropertiesIntel ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @NativeType("cl_command_queue_properties") @Unsigned long properties() { + return segment.get(LAYOUT$properties, OFFSET$properties); + } + + public CLQueueFamilyPropertiesIntel properties(@NativeType("cl_command_queue_properties") @Unsigned long value) { + segment.set(LAYOUT$properties, OFFSET$properties, value); + return this; + } + + public @NativeType("cl_command_queue_capabilities_intel") @Unsigned long capabilities() { + return segment.get(LAYOUT$capabilities, OFFSET$capabilities); + } + + public CLQueueFamilyPropertiesIntel capabilities(@NativeType("cl_command_queue_capabilities_intel") @Unsigned long value) { + segment.set(LAYOUT$capabilities, OFFSET$capabilities, value); + return this; + } + + public @NativeType("cl_uint") @Unsigned int count() { + return segment.get(LAYOUT$count, OFFSET$count); + } + + public CLQueueFamilyPropertiesIntel count(@NativeType("cl_uint") @Unsigned int value) { + segment.set(LAYOUT$count, OFFSET$count, value); + return this; + } + + public BytePtr name() { + return new BytePtr(nameRaw()); + } + + public CLQueueFamilyPropertiesIntel name(@NotNull Consumer consumer) { + BytePtr ptr = name(); + consumer.accept(ptr); + return this; + } + + public CLQueueFamilyPropertiesIntel name(BytePtr value) { + MemorySegment s = nameRaw(); + s.copyFrom(value.segment()); + return this; + } + + public @NotNull MemorySegment nameRaw() { + return segment.asSlice(OFFSET$name, SIZE$name); + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_LONG.withName("properties"), + ValueLayout.JAVA_LONG.withName("capabilities"), + ValueLayout.JAVA_INT.withName("count"), + MemoryLayout.sequenceLayout(QUEUE_FAMILY_MAX_NAME_SIZE_INTEL, ValueLayout.JAVA_BYTE).withName("name") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$properties = PathElement.groupElement("properties"); + public static final PathElement PATH$capabilities = PathElement.groupElement("capabilities"); + public static final PathElement PATH$count = PathElement.groupElement("count"); + public static final PathElement PATH$name = PathElement.groupElement("name"); + + public static final OfLong LAYOUT$properties = (OfLong) LAYOUT.select(PATH$properties); + public static final OfLong LAYOUT$capabilities = (OfLong) LAYOUT.select(PATH$capabilities); + public static final OfInt LAYOUT$count = (OfInt) LAYOUT.select(PATH$count); + public static final SequenceLayout LAYOUT$name = (SequenceLayout) LAYOUT.select(PATH$name); + + public static final long SIZE$properties = LAYOUT$properties.byteSize(); + public static final long SIZE$capabilities = LAYOUT$capabilities.byteSize(); + public static final long SIZE$count = LAYOUT$count.byteSize(); + public static final long SIZE$name = LAYOUT$name.byteSize(); + + public static final long OFFSET$properties = LAYOUT.byteOffset(PATH$properties); + public static final long OFFSET$capabilities = LAYOUT.byteOffset(PATH$capabilities); + public static final long OFFSET$count = LAYOUT.byteOffset(PATH$count); + public static final long OFFSET$name = LAYOUT.byteOffset(PATH$name); +} diff --git a/src/club/doki7/opencl/datatype/ICLBufferRegion.class b/src/club/doki7/opencl/datatype/ICLBufferRegion.class new file mode 100644 index 0000000..0af3c66 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLBufferRegion.class differ diff --git a/src/club/doki7/opencl/datatype/ICLBufferRegion.java b/src/club/doki7/opencl/datatype/ICLBufferRegion.java new file mode 100644 index 0000000..0df60a5 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLBufferRegion.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLBufferRegion} and {@link CLBufferRegion.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLBufferRegion + extends IPointer + permits CLBufferRegion, CLBufferRegion.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLDeviceIntegerDotProductAccelerationPropertiesKhr.class b/src/club/doki7/opencl/datatype/ICLDeviceIntegerDotProductAccelerationPropertiesKhr.class new file mode 100644 index 0000000..b431560 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLDeviceIntegerDotProductAccelerationPropertiesKhr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLDeviceIntegerDotProductAccelerationPropertiesKhr.java b/src/club/doki7/opencl/datatype/ICLDeviceIntegerDotProductAccelerationPropertiesKhr.java new file mode 100644 index 0000000..537ddf1 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLDeviceIntegerDotProductAccelerationPropertiesKhr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLDeviceIntegerDotProductAccelerationPropertiesKhr} and {@link CLDeviceIntegerDotProductAccelerationPropertiesKhr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLDeviceIntegerDotProductAccelerationPropertiesKhr + extends IPointer + permits CLDeviceIntegerDotProductAccelerationPropertiesKhr, CLDeviceIntegerDotProductAccelerationPropertiesKhr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLDevicePciBusInfoKhr.class b/src/club/doki7/opencl/datatype/ICLDevicePciBusInfoKhr.class new file mode 100644 index 0000000..1382ead Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLDevicePciBusInfoKhr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLDevicePciBusInfoKhr.java b/src/club/doki7/opencl/datatype/ICLDevicePciBusInfoKhr.java new file mode 100644 index 0000000..9b40c11 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLDevicePciBusInfoKhr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLDevicePciBusInfoKhr} and {@link CLDevicePciBusInfoKhr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLDevicePciBusInfoKhr + extends IPointer + permits CLDevicePciBusInfoKhr, CLDevicePciBusInfoKhr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLDx9SurfaceInfoKhr.class b/src/club/doki7/opencl/datatype/ICLDx9SurfaceInfoKhr.class new file mode 100644 index 0000000..00c2da6 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLDx9SurfaceInfoKhr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLDx9SurfaceInfoKhr.java b/src/club/doki7/opencl/datatype/ICLDx9SurfaceInfoKhr.java new file mode 100644 index 0000000..53f3361 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLDx9SurfaceInfoKhr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLDx9SurfaceInfoKhr} and {@link CLDx9SurfaceInfoKhr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLDx9SurfaceInfoKhr + extends IPointer + permits CLDx9SurfaceInfoKhr, CLDx9SurfaceInfoKhr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLImageDesc.class b/src/club/doki7/opencl/datatype/ICLImageDesc.class new file mode 100644 index 0000000..a2c9f4c Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLImageDesc.class differ diff --git a/src/club/doki7/opencl/datatype/ICLImageDesc.java b/src/club/doki7/opencl/datatype/ICLImageDesc.java new file mode 100644 index 0000000..ab3277e --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLImageDesc.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLImageDesc} and {@link CLImageDesc.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLImageDesc + extends IPointer + permits CLImageDesc, CLImageDesc.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLImageDescBufferOrMemObject.class b/src/club/doki7/opencl/datatype/ICLImageDescBufferOrMemObject.class new file mode 100644 index 0000000..77d6d8b Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLImageDescBufferOrMemObject.class differ diff --git a/src/club/doki7/opencl/datatype/ICLImageDescBufferOrMemObject.java b/src/club/doki7/opencl/datatype/ICLImageDescBufferOrMemObject.java new file mode 100644 index 0000000..687e89f --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLImageDescBufferOrMemObject.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLImageDescBufferOrMemObject} and {@link CLImageDescBufferOrMemObject.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLImageDescBufferOrMemObject + extends IPointer + permits CLImageDescBufferOrMemObject, CLImageDescBufferOrMemObject.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLImageFormat.class b/src/club/doki7/opencl/datatype/ICLImageFormat.class new file mode 100644 index 0000000..ca2d1ff Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLImageFormat.class differ diff --git a/src/club/doki7/opencl/datatype/ICLImageFormat.java b/src/club/doki7/opencl/datatype/ICLImageFormat.java new file mode 100644 index 0000000..3518487 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLImageFormat.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLImageFormat} and {@link CLImageFormat.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLImageFormat + extends IPointer + permits CLImageFormat, CLImageFormat.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLMemAndroidNativeBufferHostPtr.class b/src/club/doki7/opencl/datatype/ICLMemAndroidNativeBufferHostPtr.class new file mode 100644 index 0000000..10b0508 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLMemAndroidNativeBufferHostPtr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLMemAndroidNativeBufferHostPtr.java b/src/club/doki7/opencl/datatype/ICLMemAndroidNativeBufferHostPtr.java new file mode 100644 index 0000000..945b7df --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLMemAndroidNativeBufferHostPtr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLMemAndroidNativeBufferHostPtr} and {@link CLMemAndroidNativeBufferHostPtr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLMemAndroidNativeBufferHostPtr + extends IPointer + permits CLMemAndroidNativeBufferHostPtr, CLMemAndroidNativeBufferHostPtr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLMemExtHostPtr.class b/src/club/doki7/opencl/datatype/ICLMemExtHostPtr.class new file mode 100644 index 0000000..b712311 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLMemExtHostPtr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLMemExtHostPtr.java b/src/club/doki7/opencl/datatype/ICLMemExtHostPtr.java new file mode 100644 index 0000000..265c407 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLMemExtHostPtr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLMemExtHostPtr} and {@link CLMemExtHostPtr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLMemExtHostPtr + extends IPointer + permits CLMemExtHostPtr, CLMemExtHostPtr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLMemIonHostPtr.class b/src/club/doki7/opencl/datatype/ICLMemIonHostPtr.class new file mode 100644 index 0000000..a818398 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLMemIonHostPtr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLMemIonHostPtr.java b/src/club/doki7/opencl/datatype/ICLMemIonHostPtr.java new file mode 100644 index 0000000..e23ba1b --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLMemIonHostPtr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLMemIonHostPtr} and {@link CLMemIonHostPtr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLMemIonHostPtr + extends IPointer + permits CLMemIonHostPtr, CLMemIonHostPtr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLMotionEstimationDescIntel.class b/src/club/doki7/opencl/datatype/ICLMotionEstimationDescIntel.class new file mode 100644 index 0000000..5cb71aa Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLMotionEstimationDescIntel.class differ diff --git a/src/club/doki7/opencl/datatype/ICLMotionEstimationDescIntel.java b/src/club/doki7/opencl/datatype/ICLMotionEstimationDescIntel.java new file mode 100644 index 0000000..0ef0191 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLMotionEstimationDescIntel.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLMotionEstimationDescIntel} and {@link CLMotionEstimationDescIntel.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLMotionEstimationDescIntel + extends IPointer + permits CLMotionEstimationDescIntel, CLMotionEstimationDescIntel.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLMutableDispatchArgKhr.class b/src/club/doki7/opencl/datatype/ICLMutableDispatchArgKhr.class new file mode 100644 index 0000000..0536bef Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLMutableDispatchArgKhr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLMutableDispatchArgKhr.java b/src/club/doki7/opencl/datatype/ICLMutableDispatchArgKhr.java new file mode 100644 index 0000000..9080ab0 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLMutableDispatchArgKhr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLMutableDispatchArgKhr} and {@link CLMutableDispatchArgKhr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLMutableDispatchArgKhr + extends IPointer + permits CLMutableDispatchArgKhr, CLMutableDispatchArgKhr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLMutableDispatchConfigKhr.class b/src/club/doki7/opencl/datatype/ICLMutableDispatchConfigKhr.class new file mode 100644 index 0000000..ca62209 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLMutableDispatchConfigKhr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLMutableDispatchConfigKhr.java b/src/club/doki7/opencl/datatype/ICLMutableDispatchConfigKhr.java new file mode 100644 index 0000000..ad9c9a1 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLMutableDispatchConfigKhr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLMutableDispatchConfigKhr} and {@link CLMutableDispatchConfigKhr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLMutableDispatchConfigKhr + extends IPointer + permits CLMutableDispatchConfigKhr, CLMutableDispatchConfigKhr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLMutableDispatchExecInfoKhr.class b/src/club/doki7/opencl/datatype/ICLMutableDispatchExecInfoKhr.class new file mode 100644 index 0000000..fa087b5 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLMutableDispatchExecInfoKhr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLMutableDispatchExecInfoKhr.java b/src/club/doki7/opencl/datatype/ICLMutableDispatchExecInfoKhr.java new file mode 100644 index 0000000..57b7112 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLMutableDispatchExecInfoKhr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLMutableDispatchExecInfoKhr} and {@link CLMutableDispatchExecInfoKhr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLMutableDispatchExecInfoKhr + extends IPointer + permits CLMutableDispatchExecInfoKhr, CLMutableDispatchExecInfoKhr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLNameVersion.class b/src/club/doki7/opencl/datatype/ICLNameVersion.class new file mode 100644 index 0000000..51eb3e2 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLNameVersion.class differ diff --git a/src/club/doki7/opencl/datatype/ICLNameVersion.java b/src/club/doki7/opencl/datatype/ICLNameVersion.java new file mode 100644 index 0000000..4bfda89 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLNameVersion.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLNameVersion} and {@link CLNameVersion.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLNameVersion + extends IPointer + permits CLNameVersion, CLNameVersion.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLNameVersionKhr.class b/src/club/doki7/opencl/datatype/ICLNameVersionKhr.class new file mode 100644 index 0000000..811c867 Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLNameVersionKhr.class differ diff --git a/src/club/doki7/opencl/datatype/ICLNameVersionKhr.java b/src/club/doki7/opencl/datatype/ICLNameVersionKhr.java new file mode 100644 index 0000000..44131e8 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLNameVersionKhr.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLNameVersionKhr} and {@link CLNameVersionKhr.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLNameVersionKhr + extends IPointer + permits CLNameVersionKhr, CLNameVersionKhr.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/ICLQueueFamilyPropertiesIntel.class b/src/club/doki7/opencl/datatype/ICLQueueFamilyPropertiesIntel.class new file mode 100644 index 0000000..fe6ceae Binary files /dev/null and b/src/club/doki7/opencl/datatype/ICLQueueFamilyPropertiesIntel.class differ diff --git a/src/club/doki7/opencl/datatype/ICLQueueFamilyPropertiesIntel.java b/src/club/doki7/opencl/datatype/ICLQueueFamilyPropertiesIntel.java new file mode 100644 index 0000000..3420c60 --- /dev/null +++ b/src/club/doki7/opencl/datatype/ICLQueueFamilyPropertiesIntel.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link CLQueueFamilyPropertiesIntel} and {@link CLQueueFamilyPropertiesIntel.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface ICLQueueFamilyPropertiesIntel + extends IPointer + permits CLQueueFamilyPropertiesIntel, CLQueueFamilyPropertiesIntel.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/IVAImageFormatCLREF.class b/src/club/doki7/opencl/datatype/IVAImageFormatCLREF.class new file mode 100644 index 0000000..c64a64b Binary files /dev/null and b/src/club/doki7/opencl/datatype/IVAImageFormatCLREF.class differ diff --git a/src/club/doki7/opencl/datatype/IVAImageFormatCLREF.java b/src/club/doki7/opencl/datatype/IVAImageFormatCLREF.java new file mode 100644 index 0000000..a1572be --- /dev/null +++ b/src/club/doki7/opencl/datatype/IVAImageFormatCLREF.java @@ -0,0 +1,11 @@ +package club.doki7.opencl.datatype; + +import club.doki7.ffm.IPointer; + +/// Auxiliary interface for unifying {@link VAImageFormatCLREF} and {@link VAImageFormatCLREF.Ptr} operations. +/// +/// See package level documentation for more details. +public sealed interface IVAImageFormatCLREF + extends IPointer + permits VAImageFormatCLREF, VAImageFormatCLREF.Ptr +{} diff --git a/src/club/doki7/opencl/datatype/VAImageFormatCLREF$Ptr$Iter.class b/src/club/doki7/opencl/datatype/VAImageFormatCLREF$Ptr$Iter.class new file mode 100644 index 0000000..b0d3ee9 Binary files /dev/null and b/src/club/doki7/opencl/datatype/VAImageFormatCLREF$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/datatype/VAImageFormatCLREF$Ptr.class b/src/club/doki7/opencl/datatype/VAImageFormatCLREF$Ptr.class new file mode 100644 index 0000000..0850561 Binary files /dev/null and b/src/club/doki7/opencl/datatype/VAImageFormatCLREF$Ptr.class differ diff --git a/src/club/doki7/opencl/datatype/VAImageFormatCLREF.class b/src/club/doki7/opencl/datatype/VAImageFormatCLREF.class new file mode 100644 index 0000000..ce6d336 Binary files /dev/null and b/src/club/doki7/opencl/datatype/VAImageFormatCLREF.class differ diff --git a/src/club/doki7/opencl/datatype/VAImageFormatCLREF.java b/src/club/doki7/opencl/datatype/VAImageFormatCLREF.java new file mode 100644 index 0000000..ad54254 --- /dev/null +++ b/src/club/doki7/opencl/datatype/VAImageFormatCLREF.java @@ -0,0 +1,326 @@ +package club.doki7.opencl.datatype; + +import java.lang.foreign.*; +import static java.lang.foreign.ValueLayout.*; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.function.Consumer; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.NativeLayout; +import club.doki7.ffm.annotation.*; +import club.doki7.ffm.ptr.*; +import club.doki7.opencl.handle.*; +import static club.doki7.opencl.CLConstants.*; +import club.doki7.opencl.CLFunctionTypes.*; + +/// Represents a pointer to a {@code VAImageFormat} structure in native memory. +/// +/// ## Structure +/// +/// {@snippet lang=c : +/// typedef struct VAImageFormat { +/// uint32_t fourcc; // @link substring="fourcc" target="#fourcc" +/// uint32_t byte_order; // @link substring="byte_order" target="#byte_order" +/// uint32_t bits_per_pixel; // @link substring="bits_per_pixel" target="#bits_per_pixel" +/// uint32_t depth; // @link substring="depth" target="#depth" +/// uint32_t red_mask; // @link substring="red_mask" target="#red_mask" +/// uint32_t green_mask; // @link substring="green_mask" target="#green_mask" +/// uint32_t blue_mask; // @link substring="blue_mask" target="#blue_mask" +/// uint32_t alpha_mask; // @link substring="alpha_mask" target="#alpha_mask" +/// uint32_t[4] va_reserved; // @link substring="va_reserved" target="#va_reserved" +/// } VAImageFormat; +/// } +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@code LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +@ValueBasedCandidate +@UnsafeConstructor +public record VAImageFormatCLREF(@NotNull MemorySegment segment) implements IVAImageFormatCLREF { + /// Represents a pointer to / an array of null structure(s) in native memory. + /// + /// Technically speaking, this type has no difference with {@link VAImageFormatCLREF}. This type + /// is introduced mainly for user to distinguish between a pointer to a single structure + /// and a pointer to (potentially) an array of structure(s). APIs should use interface + /// IVAImageFormatCLREF to handle both types uniformly. See package level documentation for more + /// details. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@code VAImageFormatCLREF.LAYOUT.byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IVAImageFormatCLREF, Iterable { + public long size() { + return segment.byteSize() / VAImageFormatCLREF.BYTES; + } + + /// Returns (a pointer to) the structure at the given index. + /// + /// Note that unlike {@code read} series functions ({@link IntPtr#read()} for + /// example), modification on returned structure will be reflected on the original + /// structure array. So this function is called {@code at} to explicitly + /// indicate that the returned structure is a view of the original structure. + public @NotNull VAImageFormatCLREF at(long index) { + return new VAImageFormatCLREF(segment.asSlice(index * VAImageFormatCLREF.BYTES, VAImageFormatCLREF.BYTES)); + } + + public VAImageFormatCLREF.Ptr at(long index, @NotNull Consumer<@NotNull VAImageFormatCLREF> consumer) { + consumer.accept(at(index)); + return this; + } + + public void write(long index, @NotNull VAImageFormatCLREF value) { + MemorySegment s = segment.asSlice(index * VAImageFormatCLREF.BYTES, VAImageFormatCLREF.BYTES); + s.copyFrom(value.segment); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} structures, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public @NotNull Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * VAImageFormatCLREF.BYTES)); + } + + public @NotNull Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * VAImageFormatCLREF.BYTES)); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public @NotNull Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * VAImageFormatCLREF.BYTES, + (end - start) * VAImageFormatCLREF.BYTES + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * VAImageFormatCLREF.BYTES)); + } + + public VAImageFormatCLREF[] toArray() { + VAImageFormatCLREF[] ret = new VAImageFormatCLREF[(int) size()]; + for (long i = 0; i < size(); i++) { + ret[(int) i] = at(i); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the structures. + private static final class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= VAImageFormatCLREF.BYTES; + } + + @Override + public VAImageFormatCLREF next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + VAImageFormatCLREF ret = new VAImageFormatCLREF(segment.asSlice(0, VAImageFormatCLREF.BYTES)); + segment = segment.asSlice(VAImageFormatCLREF.BYTES); + return ret; + } + + private @NotNull MemorySegment segment; + } + } + + public static VAImageFormatCLREF allocate(Arena arena) { + return new VAImageFormatCLREF(arena.allocate(LAYOUT)); + } + + public static VAImageFormatCLREF.Ptr allocate(Arena arena, long count) { + MemorySegment segment = arena.allocate(LAYOUT, count); + return new VAImageFormatCLREF.Ptr(segment); + } + + public static VAImageFormatCLREF clone(Arena arena, VAImageFormatCLREF src) { + VAImageFormatCLREF ret = allocate(arena); + ret.segment.copyFrom(src.segment); + return ret; + } + + public @Unsigned int fourcc() { + return segment.get(LAYOUT$fourcc, OFFSET$fourcc); + } + + public VAImageFormatCLREF fourcc(@Unsigned int value) { + segment.set(LAYOUT$fourcc, OFFSET$fourcc, value); + return this; + } + + public @Unsigned int byte_order() { + return segment.get(LAYOUT$byte_order, OFFSET$byte_order); + } + + public VAImageFormatCLREF byte_order(@Unsigned int value) { + segment.set(LAYOUT$byte_order, OFFSET$byte_order, value); + return this; + } + + public @Unsigned int bits_per_pixel() { + return segment.get(LAYOUT$bits_per_pixel, OFFSET$bits_per_pixel); + } + + public VAImageFormatCLREF bits_per_pixel(@Unsigned int value) { + segment.set(LAYOUT$bits_per_pixel, OFFSET$bits_per_pixel, value); + return this; + } + + public @Unsigned int depth() { + return segment.get(LAYOUT$depth, OFFSET$depth); + } + + public VAImageFormatCLREF depth(@Unsigned int value) { + segment.set(LAYOUT$depth, OFFSET$depth, value); + return this; + } + + public @Unsigned int red_mask() { + return segment.get(LAYOUT$red_mask, OFFSET$red_mask); + } + + public VAImageFormatCLREF red_mask(@Unsigned int value) { + segment.set(LAYOUT$red_mask, OFFSET$red_mask, value); + return this; + } + + public @Unsigned int green_mask() { + return segment.get(LAYOUT$green_mask, OFFSET$green_mask); + } + + public VAImageFormatCLREF green_mask(@Unsigned int value) { + segment.set(LAYOUT$green_mask, OFFSET$green_mask, value); + return this; + } + + public @Unsigned int blue_mask() { + return segment.get(LAYOUT$blue_mask, OFFSET$blue_mask); + } + + public VAImageFormatCLREF blue_mask(@Unsigned int value) { + segment.set(LAYOUT$blue_mask, OFFSET$blue_mask, value); + return this; + } + + public @Unsigned int alpha_mask() { + return segment.get(LAYOUT$alpha_mask, OFFSET$alpha_mask); + } + + public VAImageFormatCLREF alpha_mask(@Unsigned int value) { + segment.set(LAYOUT$alpha_mask, OFFSET$alpha_mask, value); + return this; + } + + public @Unsigned IntPtr va_reserved() { + return new IntPtr(va_reservedRaw()); + } + + public VAImageFormatCLREF va_reserved(@NotNull Consumer consumer) { + @Unsigned IntPtr ptr = va_reserved(); + consumer.accept(ptr); + return this; + } + + public VAImageFormatCLREF va_reserved(@Unsigned IntPtr value) { + MemorySegment s = va_reservedRaw(); + s.copyFrom(value.segment()); + return this; + } + + public @NotNull MemorySegment va_reservedRaw() { + return segment.asSlice(OFFSET$va_reserved, SIZE$va_reserved); + } + + public static final StructLayout LAYOUT = NativeLayout.structLayout( + ValueLayout.JAVA_INT.withName("fourcc"), + ValueLayout.JAVA_INT.withName("byte_order"), + ValueLayout.JAVA_INT.withName("bits_per_pixel"), + ValueLayout.JAVA_INT.withName("depth"), + ValueLayout.JAVA_INT.withName("red_mask"), + ValueLayout.JAVA_INT.withName("green_mask"), + ValueLayout.JAVA_INT.withName("blue_mask"), + ValueLayout.JAVA_INT.withName("alpha_mask"), + MemoryLayout.sequenceLayout(4, ValueLayout.JAVA_INT).withName("va_reserved") + ); + public static final long BYTES = LAYOUT.byteSize(); + + public static final PathElement PATH$fourcc = PathElement.groupElement("fourcc"); + public static final PathElement PATH$byte_order = PathElement.groupElement("byte_order"); + public static final PathElement PATH$bits_per_pixel = PathElement.groupElement("bits_per_pixel"); + public static final PathElement PATH$depth = PathElement.groupElement("depth"); + public static final PathElement PATH$red_mask = PathElement.groupElement("red_mask"); + public static final PathElement PATH$green_mask = PathElement.groupElement("green_mask"); + public static final PathElement PATH$blue_mask = PathElement.groupElement("blue_mask"); + public static final PathElement PATH$alpha_mask = PathElement.groupElement("alpha_mask"); + public static final PathElement PATH$va_reserved = PathElement.groupElement("va_reserved"); + + public static final OfInt LAYOUT$fourcc = (OfInt) LAYOUT.select(PATH$fourcc); + public static final OfInt LAYOUT$byte_order = (OfInt) LAYOUT.select(PATH$byte_order); + public static final OfInt LAYOUT$bits_per_pixel = (OfInt) LAYOUT.select(PATH$bits_per_pixel); + public static final OfInt LAYOUT$depth = (OfInt) LAYOUT.select(PATH$depth); + public static final OfInt LAYOUT$red_mask = (OfInt) LAYOUT.select(PATH$red_mask); + public static final OfInt LAYOUT$green_mask = (OfInt) LAYOUT.select(PATH$green_mask); + public static final OfInt LAYOUT$blue_mask = (OfInt) LAYOUT.select(PATH$blue_mask); + public static final OfInt LAYOUT$alpha_mask = (OfInt) LAYOUT.select(PATH$alpha_mask); + public static final SequenceLayout LAYOUT$va_reserved = (SequenceLayout) LAYOUT.select(PATH$va_reserved); + + public static final long SIZE$fourcc = LAYOUT$fourcc.byteSize(); + public static final long SIZE$byte_order = LAYOUT$byte_order.byteSize(); + public static final long SIZE$bits_per_pixel = LAYOUT$bits_per_pixel.byteSize(); + public static final long SIZE$depth = LAYOUT$depth.byteSize(); + public static final long SIZE$red_mask = LAYOUT$red_mask.byteSize(); + public static final long SIZE$green_mask = LAYOUT$green_mask.byteSize(); + public static final long SIZE$blue_mask = LAYOUT$blue_mask.byteSize(); + public static final long SIZE$alpha_mask = LAYOUT$alpha_mask.byteSize(); + public static final long SIZE$va_reserved = LAYOUT$va_reserved.byteSize(); + + public static final long OFFSET$fourcc = LAYOUT.byteOffset(PATH$fourcc); + public static final long OFFSET$byte_order = LAYOUT.byteOffset(PATH$byte_order); + public static final long OFFSET$bits_per_pixel = LAYOUT.byteOffset(PATH$bits_per_pixel); + public static final long OFFSET$depth = LAYOUT.byteOffset(PATH$depth); + public static final long OFFSET$red_mask = LAYOUT.byteOffset(PATH$red_mask); + public static final long OFFSET$green_mask = LAYOUT.byteOffset(PATH$green_mask); + public static final long OFFSET$blue_mask = LAYOUT.byteOffset(PATH$blue_mask); + public static final long OFFSET$alpha_mask = LAYOUT.byteOffset(PATH$alpha_mask); + public static final long OFFSET$va_reserved = LAYOUT.byteOffset(PATH$va_reserved); +} diff --git a/src/club/doki7/opencl/handle/CLAcceleratorIntel$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLAcceleratorIntel$Ptr$Iter.class new file mode 100644 index 0000000..ed071cd Binary files /dev/null and b/src/club/doki7/opencl/handle/CLAcceleratorIntel$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLAcceleratorIntel$Ptr.class b/src/club/doki7/opencl/handle/CLAcceleratorIntel$Ptr.class new file mode 100644 index 0000000..834326f Binary files /dev/null and b/src/club/doki7/opencl/handle/CLAcceleratorIntel$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLAcceleratorIntel.class b/src/club/doki7/opencl/handle/CLAcceleratorIntel.class new file mode 100644 index 0000000..71563bf Binary files /dev/null and b/src/club/doki7/opencl/handle/CLAcceleratorIntel.class differ diff --git a/src/club/doki7/opencl/handle/CLAcceleratorIntel.java b/src/club/doki7/opencl/handle/CLAcceleratorIntel.java new file mode 100644 index 0000000..c97c1a9 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLAcceleratorIntel.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_accelerator_intel. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_accelerator_intel +@ValueBasedCandidate +@UnsafeConstructor +public record CLAcceleratorIntel(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_accelerator_intel handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLAcceleratorIntel read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLAcceleratorIntel(s); + } + + public void write(@Nullable CLAcceleratorIntel value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLAcceleratorIntel read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLAcceleratorIntel(s); + } + + public void write(long index, @Nullable CLAcceleratorIntel value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLAcceleratorIntel[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLAcceleratorIntel value0, @Nullable CLAcceleratorIntel ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLAcceleratorIntel @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLAcceleratorIntel> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLAcceleratorIntel value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLAcceleratorIntel value0, @Nullable CLAcceleratorIntel ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLAcceleratorIntel next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLAcceleratorIntel(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLCommandBufferKhr$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLCommandBufferKhr$Ptr$Iter.class new file mode 100644 index 0000000..1036bfe Binary files /dev/null and b/src/club/doki7/opencl/handle/CLCommandBufferKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLCommandBufferKhr$Ptr.class b/src/club/doki7/opencl/handle/CLCommandBufferKhr$Ptr.class new file mode 100644 index 0000000..ba83c8f Binary files /dev/null and b/src/club/doki7/opencl/handle/CLCommandBufferKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLCommandBufferKhr.class b/src/club/doki7/opencl/handle/CLCommandBufferKhr.class new file mode 100644 index 0000000..22fa8f0 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLCommandBufferKhr.class differ diff --git a/src/club/doki7/opencl/handle/CLCommandBufferKhr.java b/src/club/doki7/opencl/handle/CLCommandBufferKhr.java new file mode 100644 index 0000000..11b3684 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLCommandBufferKhr.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_command_buffer_khr. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_command_buffer_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLCommandBufferKhr(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_command_buffer_khr handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLCommandBufferKhr read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLCommandBufferKhr(s); + } + + public void write(@Nullable CLCommandBufferKhr value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLCommandBufferKhr read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLCommandBufferKhr(s); + } + + public void write(long index, @Nullable CLCommandBufferKhr value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLCommandBufferKhr[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLCommandBufferKhr value0, @Nullable CLCommandBufferKhr ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLCommandBufferKhr @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLCommandBufferKhr> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLCommandBufferKhr value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLCommandBufferKhr value0, @Nullable CLCommandBufferKhr ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLCommandBufferKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLCommandBufferKhr(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLCommandQueue$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLCommandQueue$Ptr$Iter.class new file mode 100644 index 0000000..b9457a7 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLCommandQueue$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLCommandQueue$Ptr.class b/src/club/doki7/opencl/handle/CLCommandQueue$Ptr.class new file mode 100644 index 0000000..a8d7c91 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLCommandQueue$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLCommandQueue.class b/src/club/doki7/opencl/handle/CLCommandQueue.class new file mode 100644 index 0000000..cff0c78 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLCommandQueue.class differ diff --git a/src/club/doki7/opencl/handle/CLCommandQueue.java b/src/club/doki7/opencl/handle/CLCommandQueue.java new file mode 100644 index 0000000..ea3f7ce --- /dev/null +++ b/src/club/doki7/opencl/handle/CLCommandQueue.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_command_queue. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_command_queue +@ValueBasedCandidate +@UnsafeConstructor +public record CLCommandQueue(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_command_queue handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLCommandQueue read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLCommandQueue(s); + } + + public void write(@Nullable CLCommandQueue value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLCommandQueue read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLCommandQueue(s); + } + + public void write(long index, @Nullable CLCommandQueue value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLCommandQueue[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLCommandQueue value0, @Nullable CLCommandQueue ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLCommandQueue @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLCommandQueue> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLCommandQueue value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLCommandQueue value0, @Nullable CLCommandQueue ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLCommandQueue next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLCommandQueue(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLContext$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLContext$Ptr$Iter.class new file mode 100644 index 0000000..8615e4c Binary files /dev/null and b/src/club/doki7/opencl/handle/CLContext$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLContext$Ptr.class b/src/club/doki7/opencl/handle/CLContext$Ptr.class new file mode 100644 index 0000000..5db483d Binary files /dev/null and b/src/club/doki7/opencl/handle/CLContext$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLContext.class b/src/club/doki7/opencl/handle/CLContext.class new file mode 100644 index 0000000..5d0fc7b Binary files /dev/null and b/src/club/doki7/opencl/handle/CLContext.class differ diff --git a/src/club/doki7/opencl/handle/CLContext.java b/src/club/doki7/opencl/handle/CLContext.java new file mode 100644 index 0000000..da4f7dc --- /dev/null +++ b/src/club/doki7/opencl/handle/CLContext.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_context. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_context +@ValueBasedCandidate +@UnsafeConstructor +public record CLContext(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_context handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLContext read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLContext(s); + } + + public void write(@Nullable CLContext value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLContext read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLContext(s); + } + + public void write(long index, @Nullable CLContext value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLContext[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLContext value0, @Nullable CLContext ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLContext @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLContext> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLContext value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLContext value0, @Nullable CLContext ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLContext next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLContext(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLDeviceId$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLDeviceId$Ptr$Iter.class new file mode 100644 index 0000000..6505f95 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLDeviceId$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLDeviceId$Ptr.class b/src/club/doki7/opencl/handle/CLDeviceId$Ptr.class new file mode 100644 index 0000000..fd92a43 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLDeviceId$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLDeviceId.class b/src/club/doki7/opencl/handle/CLDeviceId.class new file mode 100644 index 0000000..9cfc3d3 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLDeviceId.class differ diff --git a/src/club/doki7/opencl/handle/CLDeviceId.java b/src/club/doki7/opencl/handle/CLDeviceId.java new file mode 100644 index 0000000..9fc8788 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLDeviceId.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_device_id. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_device_id +@ValueBasedCandidate +@UnsafeConstructor +public record CLDeviceId(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_device_id handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLDeviceId read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLDeviceId(s); + } + + public void write(@Nullable CLDeviceId value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLDeviceId read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLDeviceId(s); + } + + public void write(long index, @Nullable CLDeviceId value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLDeviceId[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLDeviceId value0, @Nullable CLDeviceId ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLDeviceId @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLDeviceId> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLDeviceId value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLDeviceId value0, @Nullable CLDeviceId ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLDeviceId next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLDeviceId(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLEvent$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLEvent$Ptr$Iter.class new file mode 100644 index 0000000..c3d7690 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLEvent$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLEvent$Ptr.class b/src/club/doki7/opencl/handle/CLEvent$Ptr.class new file mode 100644 index 0000000..57cc6f1 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLEvent$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLEvent.class b/src/club/doki7/opencl/handle/CLEvent.class new file mode 100644 index 0000000..3bddfb3 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLEvent.class differ diff --git a/src/club/doki7/opencl/handle/CLEvent.java b/src/club/doki7/opencl/handle/CLEvent.java new file mode 100644 index 0000000..19d2485 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLEvent.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_event. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_event +@ValueBasedCandidate +@UnsafeConstructor +public record CLEvent(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_event handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLEvent read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLEvent(s); + } + + public void write(@Nullable CLEvent value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLEvent read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLEvent(s); + } + + public void write(long index, @Nullable CLEvent value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLEvent[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLEvent value0, @Nullable CLEvent ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLEvent @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLEvent> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLEvent value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLEvent value0, @Nullable CLEvent ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLEvent next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLEvent(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLGLsync$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLGLsync$Ptr$Iter.class new file mode 100644 index 0000000..1e1501c Binary files /dev/null and b/src/club/doki7/opencl/handle/CLGLsync$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLGLsync$Ptr.class b/src/club/doki7/opencl/handle/CLGLsync$Ptr.class new file mode 100644 index 0000000..d74b2d0 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLGLsync$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLGLsync.class b/src/club/doki7/opencl/handle/CLGLsync.class new file mode 100644 index 0000000..465eddb Binary files /dev/null and b/src/club/doki7/opencl/handle/CLGLsync.class differ diff --git a/src/club/doki7/opencl/handle/CLGLsync.java b/src/club/doki7/opencl/handle/CLGLsync.java new file mode 100644 index 0000000..37f851c --- /dev/null +++ b/src/club/doki7/opencl/handle/CLGLsync.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_GLsync. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_GLsync +@ValueBasedCandidate +@UnsafeConstructor +public record CLGLsync(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_GLsync handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLGLsync read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLGLsync(s); + } + + public void write(@Nullable CLGLsync value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLGLsync read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLGLsync(s); + } + + public void write(long index, @Nullable CLGLsync value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLGLsync[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLGLsync value0, @Nullable CLGLsync ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLGLsync @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLGLsync> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLGLsync value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLGLsync value0, @Nullable CLGLsync ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLGLsync next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLGLsync(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLIcdDispatch$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLIcdDispatch$Ptr$Iter.class new file mode 100644 index 0000000..3bd0097 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLIcdDispatch$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLIcdDispatch$Ptr.class b/src/club/doki7/opencl/handle/CLIcdDispatch$Ptr.class new file mode 100644 index 0000000..d12561f Binary files /dev/null and b/src/club/doki7/opencl/handle/CLIcdDispatch$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLIcdDispatch.class b/src/club/doki7/opencl/handle/CLIcdDispatch.class new file mode 100644 index 0000000..1e8834f Binary files /dev/null and b/src/club/doki7/opencl/handle/CLIcdDispatch.class differ diff --git a/src/club/doki7/opencl/handle/CLIcdDispatch.java b/src/club/doki7/opencl/handle/CLIcdDispatch.java new file mode 100644 index 0000000..5ec1447 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLIcdDispatch.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_icd_dispatch. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_icd_dispatch +@ValueBasedCandidate +@UnsafeConstructor +public record CLIcdDispatch(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_icd_dispatch handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLIcdDispatch read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLIcdDispatch(s); + } + + public void write(@Nullable CLIcdDispatch value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLIcdDispatch read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLIcdDispatch(s); + } + + public void write(long index, @Nullable CLIcdDispatch value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLIcdDispatch[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLIcdDispatch value0, @Nullable CLIcdDispatch ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLIcdDispatch @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLIcdDispatch> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLIcdDispatch value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLIcdDispatch value0, @Nullable CLIcdDispatch ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLIcdDispatch next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLIcdDispatch(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLKernel$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLKernel$Ptr$Iter.class new file mode 100644 index 0000000..d0e5d53 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLKernel$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLKernel$Ptr.class b/src/club/doki7/opencl/handle/CLKernel$Ptr.class new file mode 100644 index 0000000..e66a08b Binary files /dev/null and b/src/club/doki7/opencl/handle/CLKernel$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLKernel.class b/src/club/doki7/opencl/handle/CLKernel.class new file mode 100644 index 0000000..544c300 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLKernel.class differ diff --git a/src/club/doki7/opencl/handle/CLKernel.java b/src/club/doki7/opencl/handle/CLKernel.java new file mode 100644 index 0000000..bb2c4f6 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLKernel.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_kernel. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_kernel +@ValueBasedCandidate +@UnsafeConstructor +public record CLKernel(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_kernel handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLKernel read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLKernel(s); + } + + public void write(@Nullable CLKernel value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLKernel read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLKernel(s); + } + + public void write(long index, @Nullable CLKernel value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLKernel[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLKernel value0, @Nullable CLKernel ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLKernel @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLKernel> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLKernel value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLKernel value0, @Nullable CLKernel ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLKernel next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLKernel(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLMem$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLMem$Ptr$Iter.class new file mode 100644 index 0000000..6a5ed02 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLMem$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLMem$Ptr.class b/src/club/doki7/opencl/handle/CLMem$Ptr.class new file mode 100644 index 0000000..bcc5121 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLMem$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLMem.class b/src/club/doki7/opencl/handle/CLMem.class new file mode 100644 index 0000000..fac2a7b Binary files /dev/null and b/src/club/doki7/opencl/handle/CLMem.class differ diff --git a/src/club/doki7/opencl/handle/CLMem.java b/src/club/doki7/opencl/handle/CLMem.java new file mode 100644 index 0000000..98e6898 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLMem.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_mem. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_mem +@ValueBasedCandidate +@UnsafeConstructor +public record CLMem(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_mem handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLMem read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMem(s); + } + + public void write(@Nullable CLMem value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLMem read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMem(s); + } + + public void write(long index, @Nullable CLMem value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLMem[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLMem value0, @Nullable CLMem ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLMem @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLMem> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLMem value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLMem value0, @Nullable CLMem ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLMem next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLMem(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLMutableCommandKhr$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLMutableCommandKhr$Ptr$Iter.class new file mode 100644 index 0000000..c66fd68 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLMutableCommandKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLMutableCommandKhr$Ptr.class b/src/club/doki7/opencl/handle/CLMutableCommandKhr$Ptr.class new file mode 100644 index 0000000..0ac4c1d Binary files /dev/null and b/src/club/doki7/opencl/handle/CLMutableCommandKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLMutableCommandKhr.class b/src/club/doki7/opencl/handle/CLMutableCommandKhr.class new file mode 100644 index 0000000..ed82a42 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLMutableCommandKhr.class differ diff --git a/src/club/doki7/opencl/handle/CLMutableCommandKhr.java b/src/club/doki7/opencl/handle/CLMutableCommandKhr.java new file mode 100644 index 0000000..f2f11b0 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLMutableCommandKhr.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_mutable_command_khr. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_mutable_command_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLMutableCommandKhr(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_mutable_command_khr handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLMutableCommandKhr read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMutableCommandKhr(s); + } + + public void write(@Nullable CLMutableCommandKhr value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLMutableCommandKhr read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLMutableCommandKhr(s); + } + + public void write(long index, @Nullable CLMutableCommandKhr value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLMutableCommandKhr[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLMutableCommandKhr value0, @Nullable CLMutableCommandKhr ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLMutableCommandKhr @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLMutableCommandKhr> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLMutableCommandKhr value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLMutableCommandKhr value0, @Nullable CLMutableCommandKhr ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLMutableCommandKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLMutableCommandKhr(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLPlatformId$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLPlatformId$Ptr$Iter.class new file mode 100644 index 0000000..8cfb838 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLPlatformId$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLPlatformId$Ptr.class b/src/club/doki7/opencl/handle/CLPlatformId$Ptr.class new file mode 100644 index 0000000..ee2ff54 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLPlatformId$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLPlatformId.class b/src/club/doki7/opencl/handle/CLPlatformId.class new file mode 100644 index 0000000..be3818f Binary files /dev/null and b/src/club/doki7/opencl/handle/CLPlatformId.class differ diff --git a/src/club/doki7/opencl/handle/CLPlatformId.java b/src/club/doki7/opencl/handle/CLPlatformId.java new file mode 100644 index 0000000..86096df --- /dev/null +++ b/src/club/doki7/opencl/handle/CLPlatformId.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_platform_id. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_platform_id +@ValueBasedCandidate +@UnsafeConstructor +public record CLPlatformId(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_platform_id handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLPlatformId read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLPlatformId(s); + } + + public void write(@Nullable CLPlatformId value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLPlatformId read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLPlatformId(s); + } + + public void write(long index, @Nullable CLPlatformId value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLPlatformId[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLPlatformId value0, @Nullable CLPlatformId ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLPlatformId @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLPlatformId> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLPlatformId value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLPlatformId value0, @Nullable CLPlatformId ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLPlatformId next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLPlatformId(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLProgram$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLProgram$Ptr$Iter.class new file mode 100644 index 0000000..b67197c Binary files /dev/null and b/src/club/doki7/opencl/handle/CLProgram$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLProgram$Ptr.class b/src/club/doki7/opencl/handle/CLProgram$Ptr.class new file mode 100644 index 0000000..3678cf1 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLProgram$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLProgram.class b/src/club/doki7/opencl/handle/CLProgram.class new file mode 100644 index 0000000..514cc82 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLProgram.class differ diff --git a/src/club/doki7/opencl/handle/CLProgram.java b/src/club/doki7/opencl/handle/CLProgram.java new file mode 100644 index 0000000..11de4ab --- /dev/null +++ b/src/club/doki7/opencl/handle/CLProgram.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_program. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_program +@ValueBasedCandidate +@UnsafeConstructor +public record CLProgram(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_program handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLProgram read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLProgram(s); + } + + public void write(@Nullable CLProgram value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLProgram read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLProgram(s); + } + + public void write(long index, @Nullable CLProgram value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLProgram[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLProgram value0, @Nullable CLProgram ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLProgram @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLProgram> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLProgram value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLProgram value0, @Nullable CLProgram ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLProgram next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLProgram(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLSampler$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLSampler$Ptr$Iter.class new file mode 100644 index 0000000..44711a8 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLSampler$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLSampler$Ptr.class b/src/club/doki7/opencl/handle/CLSampler$Ptr.class new file mode 100644 index 0000000..5389a95 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLSampler$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLSampler.class b/src/club/doki7/opencl/handle/CLSampler.class new file mode 100644 index 0000000..20d8956 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLSampler.class differ diff --git a/src/club/doki7/opencl/handle/CLSampler.java b/src/club/doki7/opencl/handle/CLSampler.java new file mode 100644 index 0000000..feabcdf --- /dev/null +++ b/src/club/doki7/opencl/handle/CLSampler.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_sampler. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_sampler +@ValueBasedCandidate +@UnsafeConstructor +public record CLSampler(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_sampler handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLSampler read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLSampler(s); + } + + public void write(@Nullable CLSampler value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLSampler read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLSampler(s); + } + + public void write(long index, @Nullable CLSampler value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLSampler[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLSampler value0, @Nullable CLSampler ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLSampler @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLSampler> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLSampler value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLSampler value0, @Nullable CLSampler ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLSampler next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLSampler(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/club/doki7/opencl/handle/CLSemaphoreKhr$Ptr$Iter.class b/src/club/doki7/opencl/handle/CLSemaphoreKhr$Ptr$Iter.class new file mode 100644 index 0000000..0cf87af Binary files /dev/null and b/src/club/doki7/opencl/handle/CLSemaphoreKhr$Ptr$Iter.class differ diff --git a/src/club/doki7/opencl/handle/CLSemaphoreKhr$Ptr.class b/src/club/doki7/opencl/handle/CLSemaphoreKhr$Ptr.class new file mode 100644 index 0000000..ce05028 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLSemaphoreKhr$Ptr.class differ diff --git a/src/club/doki7/opencl/handle/CLSemaphoreKhr.class b/src/club/doki7/opencl/handle/CLSemaphoreKhr.class new file mode 100644 index 0000000..8726c69 Binary files /dev/null and b/src/club/doki7/opencl/handle/CLSemaphoreKhr.class differ diff --git a/src/club/doki7/opencl/handle/CLSemaphoreKhr.java b/src/club/doki7/opencl/handle/CLSemaphoreKhr.java new file mode 100644 index 0000000..0410631 --- /dev/null +++ b/src/club/doki7/opencl/handle/CLSemaphoreKhr.java @@ -0,0 +1,200 @@ +package club.doki7.opencl.handle; + +import java.lang.foreign.*; +import java.util.Collection; +import java.util.List; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; +import club.doki7.ffm.IPointer; +import club.doki7.ffm.annotation.*; + +/// Represents an opaque handle type cl_semaphore_khr. +/// +/// ## Contracts +/// +/// The property {@link #segment()} should always be not-null +/// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to +/// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java +/// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. +/// +/// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not +/// perform any runtime check. The constructor can be useful for automatic code generators. +/// +/// @see cl_semaphore_khr +@ValueBasedCandidate +@UnsafeConstructor +public record CLSemaphoreKhr(@NotNull MemorySegment segment) implements IPointer { + /// Represents a pointer to cl_semaphore_khr handle(s) in native memory. + /// + /// ## Contracts + /// + /// The property {@link #segment()} should always be not-null + /// ({@code segment != NULL && !segment.equals(MemorySegment.NULL)}), and properly aligned to + /// {@link AddressLayout#byteAlignment()} bytes. To represent null pointer, you may use a Java + /// {@code null} instead. See the documentation of {@link IPointer#segment()} for more details. + /// + /// The constructor of this class is marked as {@link UnsafeConstructor}, because it does not + /// perform any runtime check. The constructor can be useful for automatic code generators. + @ValueBasedCandidate + @UnsafeConstructor + public record Ptr(@NotNull MemorySegment segment) implements IPointer, Iterable { + public long size() { + return segment.byteSize() / ValueLayout.ADDRESS.byteSize(); + } + + public @Nullable CLSemaphoreKhr read() { + MemorySegment s = readRaw(); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLSemaphoreKhr(s); + } + + public void write(@Nullable CLSemaphoreKhr value) { + writeRaw(value == null ? MemorySegment.NULL : value.segment()); + } + + public @Nullable CLSemaphoreKhr read(long index) { + MemorySegment s = readRaw(index); + if (s.equals(MemorySegment.NULL)) { + return null; + } + return new CLSemaphoreKhr(s); + } + + public void write(long index, @Nullable CLSemaphoreKhr value) { + writeRaw(index, value == null ? MemorySegment.NULL : value.segment()); + } + + public void write(@Nullable CLSemaphoreKhr[] values) { + for (int i = 0; i < values.length; i++) { + write(i, values[i]); + } + } + + public void writeV(@Nullable CLSemaphoreKhr value0, @Nullable CLSemaphoreKhr ...values) { + write(value0); + for (int i = 0; i < values.length; i++) { + write(i + 1, values[i]); + } + } + + public @NotNull MemorySegment readRaw() { + return segment.get(ValueLayout.ADDRESS, 0); + } + + public @NotNull MemorySegment readRaw(long index) { + return segment.get(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize()); + } + + public void writeRaw(@NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, 0, value); + } + + public void writeRaw(long index, @NotNull MemorySegment value) { + segment.set(ValueLayout.ADDRESS, index * ValueLayout.ADDRESS.byteSize(), value); + } + + /// Assume the {@link Ptr} is capable of holding at least {@code newSize} handles, + /// create a new view {@link Ptr} that uses the same backing storage as this + /// {@link Ptr}, but with the new size. Since there is actually no way to really check + /// whether the new size is valid, while buffer overflow is undefined behavior, this method is + /// marked as {@link Unsafe}. + /// + /// This method could be useful when handling data returned from some C API, where the size of + /// the data is not known in advance. + /// + /// If the size of the underlying segment is actually known in advance and correctly set, and + /// you want to create a shrunk view, you may use {@link #slice(long)} (with validation) + /// instead. + @Unsafe + public Ptr reinterpret(long newSize) { + return new Ptr(segment.reinterpret(newSize * ValueLayout.ADDRESS.byteSize())); + } + + public Ptr offset(long offset) { + return new Ptr(segment.asSlice(offset * ValueLayout.ADDRESS.byteSize())); + } + + /// Note that this function uses the {@link List#subList(int, int)} semantics (left inclusive, + /// right exclusive interval), not {@link MemorySegment#asSlice(long, long)} semantics + /// (offset + newSize). Be careful with the difference + public Ptr slice(long start, long end) { + return new Ptr(segment.asSlice( + start * ValueLayout.ADDRESS.byteSize(), + (end - start) * ValueLayout.ADDRESS.byteSize() + )); + } + + public Ptr slice(long end) { + return new Ptr(segment.asSlice(0, end * ValueLayout.ADDRESS.byteSize())); + } + + public static Ptr allocate(Arena arena) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS)); + } + + public static Ptr allocate(Arena arena, long size) { + return new Ptr(arena.allocate(ValueLayout.ADDRESS, size)); + } + + public static Ptr allocate(Arena arena, @Nullable CLSemaphoreKhr @NotNull [] values) { + Ptr ret = allocate(arena, values.length); + for (int i = 0; i < values.length; i++) { + ret.write(i, values[i]); + } + return ret; + } + + public static Ptr allocate(Arena arena, @NotNull Collection<@Nullable CLSemaphoreKhr> values) { + Ptr ret = allocate(arena, values.size()); + int i = 0; + for (@Nullable CLSemaphoreKhr value : values) { + ret.write(i, value); + i += 1; + } + return ret; + } + + public static Ptr allocateV(Arena arena, @Nullable CLSemaphoreKhr value0, @Nullable CLSemaphoreKhr ...values) { + Ptr ret = allocate(arena, values.length + 1); + ret.write(0, value0); + for (int i = 0; i < values.length; i++) { + ret.write(i + 1, values[i]); + } + return ret; + } + + @Override + public @NotNull Iterator iterator() { + return new Iter(this.segment()); + } + + /// An iterator over the handles. + private static class Iter implements Iterator { + Iter(@NotNull MemorySegment segment) { + this.segment = segment; + } + + @Override + public boolean hasNext() { + return segment.byteSize() >= ValueLayout.ADDRESS.byteSize(); + } + + @Override + public @Nullable CLSemaphoreKhr next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + MemorySegment s = segment.get(ValueLayout.ADDRESS, 0); + segment = segment.asSlice(ValueLayout.ADDRESS.byteSize()); + return s.equals(MemorySegment.NULL) ? null : new CLSemaphoreKhr(s); + } + + private @NotNull MemorySegment segment; + } + } +} diff --git a/src/org/kne/opencl64/CLUtils.java b/src/org/kne/opencl64/CLUtils.java new file mode 100644 index 0000000..3fca740 --- /dev/null +++ b/src/org/kne/opencl64/CLUtils.java @@ -0,0 +1,1343 @@ +package org.kne.opencl64; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.lang.foreign.ValueLayout.OfInt; +import java.lang.foreign.ValueLayout.OfLong; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; + +import club.doki7.ffm.ptr.IntPtr; +import club.doki7.ffm.ptr.PointerPtr; +import club.doki7.opencl.CL; +import club.doki7.opencl.CLConstants; +import club.doki7.opencl.handle.CLDeviceId; +import club.doki7.opencl.handle.CLPlatformId; +import club.doki7.opencl.handle.CLProgram; + +public class CLUtils { + private CL opencl; + + public CLUtils(CL opencl) { + this.opencl=opencl; + } + + /** + * Returns the value of the device info parameter with the given name + * + * @param device The device + * @param paramName The parameter name + * @return The value + */ + public int getInt(CLDeviceId device, int paramName) + { + return getInts(device, paramName, 1).getAtIndex(OfInt.JAVA_INT, 0); + } + + /** + * Returns the values of the device info parameter with the given name + * + * @param device The device + * @param paramName The parameter name + * @param numValues The number of values + * @return The value + */ + public MemorySegment getInts(CLDeviceId device, int paramName, int numValues) + { + MemorySegment values = Arena.ofAuto().allocate(4*numValues); + int errcode =opencl.getDeviceInfo(device, paramName, 4 * numValues, values, null); + CLUtils.checkResult(errcode); + return values; + } + + /** + * Returns the value of the device info parameter with the given name + * + * @param device The device + * @param paramName The parameter name + * @return The value + */ + public long getLong(CLDeviceId device, int paramName) + { + return getLongs(device, paramName, 1).getAtIndex(OfLong.JAVA_LONG, 0); + } + + /** + * Returns the values of the device info parameter with the given name + * + * @param device The device + * @param paramName The parameter name + * @param numValues The number of values + * @return The value + */ + public MemorySegment getLongs(CLDeviceId device, int paramName, int numValues) + { + MemorySegment values = Arena.ofAuto().allocate(8*numValues); + int errcode=opencl.getDeviceInfo(device, paramName, 8 * numValues, values, null); + CLUtils.checkResult(errcode); + return values; + } + + /** + * Returns the value of the device info parameter with the given name + * + * @param device The device + * @param paramName The parameter name + * @return The value + */ + public String getString(CLDeviceId device, int paramName) + { + // Obtain the length of the string that will be queried + PointerPtr size=PointerPtr.allocate(Arena.ofAuto()); + int errcode= opencl.getDeviceInfo(device, paramName, 0, MemorySegment.NULL, size); + CLUtils.checkResult(errcode); + + // Create a buffer of the appropriate size and fill it with the info + MemorySegment memseg=Arena.ofAuto().allocate(size.read().address()+1); + errcode =opencl.getDeviceInfo(device, paramName, memseg.byteSize(), memseg, size); + CLUtils.checkResult(errcode); + // Create a string from the buffer (excluding the trailing \0 byte) + return memseg.getString(0, Charset.forName("utf-8")); + // return new String(buffer, 0, buffer.length-1); + } + + /** + * Returns the value of the platform info parameter with the given name + * + * @param platform The platform + * @param paramName The parameter name + * @return The value + */ + public String getString(CLPlatformId platform, int paramName) + { + // Obtain the length of the string that will be queried + PointerPtr size=PointerPtr.allocate(Arena.ofAuto()); + int errcode=opencl.getPlatformInfo(platform, paramName, 0, MemorySegment.NULL, size); + CLUtils.checkResult(errcode); + + // Create a buffer of the appropriate size and fill it with the info + MemorySegment memseg=Arena.ofAuto().allocate(size.read().address()+1); + errcode= opencl.getPlatformInfo(platform, paramName, memseg.byteSize(), memseg, size); + CLUtils.checkResult(errcode); + // Create a string from the buffer (excluding the trailing \0 byte) + return memseg.getString(0, Charset.forName("utf-8")); + // return new String(buffer, 0, buffer.length-1); + } + + /** + * Returns the value of the device info parameter with the given name + * + * @param device The device + * @param paramName The parameter name + * @return The value + */ + public long getSize(CLDeviceId device, int paramName) + { + return getSizes(device, paramName, 1)[0]; + } + + /** + * Returns the values of the device info parameter with the given name + * + * @param device The device + * @param paramName The parameter name + * @param numValues The number of values + * @return The value + */ + public long[] getSizes(CLDeviceId device, int paramName, int numValues) + { + // The size of the returned data has to depend on + // the size of a size_t, which is handled here + long sizet=ValueLayout.ADDRESS.byteSize(); + MemorySegment buffer=Arena.ofAuto().allocate(sizet*numValues); + + int errcode=opencl.getDeviceInfo(device, paramName, sizet * numValues, + buffer, null); + CLUtils.checkResult(errcode); + long values[] = new long[numValues]; + if (sizet == 4) + { + for (int i=0; i devid,int result) { + if(result==CLConstants.BUILD_PROGRAM_FAILURE) { + if(devid==null) { + devid=cl_program.getContext().getDevices(); + } + StringBuilder builder=new StringBuilder("BUILD_PROGRAM_FAILURE\n"); + for(int i=0;i{ + defaultcopy(src, srcPos+count*j, dst, dstPos+count*j, count); + aig.incrementAndGet(); + }); + } + defaultcopy(src, srcPos+count*cores, dst, dstPos+count*cores, mod); + while(aig.get()= 1024L * 1024 * 1024 * 1024 * 1024) { + return String.format("%.2f", v / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)) + "PB"; + } else if (v >= 1024L * 1024 * 1024 * 1024) { + return String.format("%.2f", v / (1024.0 * 1024.0 * 1024.0 * 1024.0)) + "TB"; + } else if (v >= 1024L * 1024 * 1024) { + return String.format("%.2f", v / (1024.0 * 1024.0 * 1024.0)) + "GB"; + } else if (v >= 1024L * 1024) { + return String.format("%.2f", v / (1024.0 * 1024.0)) + "MB"; + } else if (v >= 1024L) { + return String.format("%.2f", v / (1024.0)) + "KB"; + } else { + return v + "B"; + } + } +} diff --git a/src/org/kne/opencl64/LocalMemType.java b/src/org/kne/opencl64/LocalMemType.java new file mode 100644 index 0000000..b6f99a5 --- /dev/null +++ b/src/org/kne/opencl64/LocalMemType.java @@ -0,0 +1,5 @@ +package org.kne.opencl64; + +public enum LocalMemType { + LOCAL,GLOBAL; +} diff --git a/src/org/kne/opencl64/OpenCLBuildProgramCallback.java b/src/org/kne/opencl64/OpenCLBuildProgramCallback.java new file mode 100644 index 0000000..2d07ba2 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLBuildProgramCallback.java @@ -0,0 +1,5 @@ +package org.kne.opencl64; + +public interface OpenCLBuildProgramCallback { + void function(OpenCLProgram program, Object user_data); +} diff --git a/src/org/kne/opencl64/OpenCLCommandQueue.java b/src/org/kne/opencl64/OpenCLCommandQueue.java new file mode 100644 index 0000000..83cab7c --- /dev/null +++ b/src/org/kne/opencl64/OpenCLCommandQueue.java @@ -0,0 +1,167 @@ +package org.kne.opencl64; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.ref.Cleaner; +import java.util.Arrays; + +import club.doki7.ffm.ptr.IntPtr; +import club.doki7.ffm.ptr.PointerPtr; +import club.doki7.opencl.CLConstants; +import club.doki7.opencl.handle.CLCommandQueue; +public class OpenCLCommandQueue { + private OpenCLContext context; + private OpenCLDevice device; + private CLCommandQueue cl_command_queue; + + private static final Cleaner clr=Cleaner.create(); + + public OpenCLContext getContext() { + return context; + } + + public OpenCLDevice getDevice() { + return device; + } + + public CLCommandQueue getCl_command_queue() { + return cl_command_queue; + } + public OpenCLCommandQueue(OpenCLContext context,OpenCLDevice device,OpenCLCommandQueueProperties properties) { + this.context=context; + this.device=device; + IntPtr errcode=IntPtr.allocate(Arena.ofAuto()); + cl_command_queue= OpenCLPlatform. opencl.createCommandQueueWithProperties( + context.getCl_context(), device.getCl_device_id(), properties.toLongProperties(), errcode); + CLUtils.checkResult(errcode); + releaser=new OpenCLCommandQueueReleaser(cl_command_queue); + clr.register(this, releaser); + } + + + + + public OpenCLCommandQueue(OpenCLContext context,OpenCLDevice device) { + this(context,device,new OpenCLCommandQueueProperties()); + } + + public void executeNDRangeKernel(OpenCLKernel kernel,long[]globalOffset,long[]globalSize) { + executeNDRangeKernel(kernel, globalOffset, globalSize, null); + } + + public void executeNDRangeKernel(OpenCLKernel kernel,long[]globalOffset,long[]globalSize,long[]localSize) { + if(globalSize==null) { + throw new NullPointerException("globalSize is null!"); + } + if(globalOffset!=null&&globalOffset.length != globalSize.length) { + throw new IllegalArgumentException("globalOffset.length != globalSize.length"); + } + if(localSize!=null&&localSize.length != globalSize.length) { + throw new IllegalArgumentException("localSize.length != globalSize.length"); + } + MemorySegment sizes=Arena.ofAuto().allocate(globalSize.length*3L*OfLong.JAVA_LONG.byteSize()); + if(globalOffset!=null) + MemorySegment.copy(globalOffset, 0, sizes, OfLong.JAVA_LONG, OfLong.JAVA_LONG.byteSize()*0, globalSize.length); + if(globalSize!=null) + MemorySegment.copy(globalSize, 0, sizes, OfLong.JAVA_LONG, OfLong.JAVA_LONG.byteSize()*globalSize.length, globalSize.length); + if(localSize!=null) + MemorySegment.copy(localSize, 0, sizes, OfLong.JAVA_LONG, OfLong.JAVA_LONG.byteSize()*globalSize.length*2, globalSize.length); + PointerPtr ptr0=globalOffset==null?null: new PointerPtr(sizes); + PointerPtr ptr1=globalSize==null?null:new PointerPtr( sizes.asSlice(1L*OfLong.JAVA_LONG.byteSize()*globalSize.length)); + PointerPtr ptr2=localSize==null?null: new PointerPtr(sizes.asSlice(2L*OfLong.JAVA_LONG.byteSize()*globalSize.length)); + int errcode=OpenCLPlatform.opencl.enqueueNDRangeKernel(cl_command_queue, kernel.getCl_kernel(), globalSize.length,ptr0,ptr1,ptr2, 0, null, null); + CLUtils.checkResult(errcode); + } + + public void execute1DRangeKernel(OpenCLKernel kernel,long globalOffset,long globalSize,long localSize) { + executeNDRangeKernel(kernel,new long[] { globalOffset},new long[] {globalSize},(localSize==-1)?null:new long[] {localSize}); + } + + public void execute1DRangeKernel(OpenCLKernel kernel,long globalOffset,long globalSize) { + execute1DRangeKernel(kernel, globalOffset, globalSize,-1); + } + + + + public void executeReadBuffer(OpenCLMemory omem, MemorySegment jmem, boolean block,long omemoffset,long jmemoffset,long size) { + if(omemoffset<0|omemoffset>=omem.getSize()) { + throw new IndexOutOfBoundsException("Index "+omemoffset+" out of bounds for length "+omem.getSize()); + } + int errcode =OpenCLPlatform.opencl.enqueueReadBuffer(cl_command_queue, omem.getCl_mem(), block?CLConstants.TRUE:CLConstants.FALSE, omemoffset, size,jmem, 0, null, null); + CLUtils.checkResult(errcode); + } + + public void executeReadBuffer(OpenCLMemory omem, MemorySegment jmem, boolean block) { + if(omem.getSize() != jmem.byteSize()) { + throw new IllegalArgumentException("omem.getSize() != jmem.byteSize(),please give offsets and size manually!"); + } + executeReadBuffer(omem, jmem, block, 0, 0, omem.getSize()); + } + + public void executeWriteBuffer(OpenCLMemory omem, MemorySegment jmem, boolean block,long omemoffset,long jmemoffset,long size) { + if(omemoffset<0|omemoffset>=omem.getSize()) { + throw new IndexOutOfBoundsException("Index "+omemoffset+" out of bounds for length "+omem.getSize()); + } + int errcode =OpenCLPlatform.opencl.enqueueWriteBuffer(cl_command_queue, omem.getCl_mem(), block?CLConstants.TRUE:CLConstants.FALSE, omemoffset, size, jmem, 0, null, null); + CLUtils.checkResult(errcode); + } + + public void executeWriteBuffer(OpenCLMemory omem, MemorySegment jmem, boolean block) { + if(omem.getSize() != jmem.byteSize()) { + throw new IllegalArgumentException("omem.getSize() != jmem.byteSize(),please give offsets and size manually!"); + } + executeWriteBuffer(omem, jmem, block, 0, 0, omem.getSize()); + } + public void executeCopyBuffer(OpenCLMemory src, OpenCLMemory dst, long srcoffset,long dstoffset,long size) { + int errcode =OpenCLPlatform.opencl.enqueueCopyBuffer(cl_command_queue, src.getCl_mem(), dst.getCl_mem(), srcoffset, dstoffset, size, 0, null, null); + CLUtils.checkResult(errcode); + } + + public MemorySegment mapBuffer(OpenCLMemory buffer,boolean block,OpenCLMapFlag mapFlag,long offset,long size) { + IntPtr errcode=IntPtr.allocate(Arena.ofAuto()); + MemorySegment mapd= OpenCLPlatform.opencl.enqueueMapBuffer(cl_command_queue, buffer.getCl_mem(), block?CLConstants.TRUE:CLConstants.FALSE, mapFlag.flags, offset, size, 0, null, null, errcode); + CLUtils.checkResult(errcode); + return mapd; + } + + public void unmapBuffer(OpenCLMemory buffer,MemorySegment mapped,boolean block) { + int errcode =OpenCLPlatform.opencl.enqueueUnmapMemObject(cl_command_queue, buffer.getCl_mem(), mapped, 0, null, null); + CLUtils.checkResult(errcode); + } + + public void finish() { + int errcode =OpenCLPlatform.opencl.finish(cl_command_queue); + CLUtils.checkResult(errcode); + } + + public void flush() { + int errcode=OpenCLPlatform.opencl.flush(cl_command_queue); + CLUtils.checkResult(errcode); + } + + private OpenCLCommandQueueReleaser releaser; + + public void close() { + releaser.run(); + } + + public boolean isClosed() { + return releaser.isReleased(); + } + + +} +class OpenCLCommandQueueReleaser extends Releaser{ + + public OpenCLCommandQueueReleaser(CLCommandQueue resource) { + super(resource); + } + + @Override + protected void release(CLCommandQueue resource) { + int errcode=OpenCLPlatform.opencl.releaseCommandQueue(resource); + CLUtils.checkResult(errcode); + } + +} \ No newline at end of file diff --git a/src/org/kne/opencl64/OpenCLCommandQueueProperties.java b/src/org/kne/opencl64/OpenCLCommandQueueProperties.java new file mode 100644 index 0000000..76bc268 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLCommandQueueProperties.java @@ -0,0 +1,10 @@ +package org.kne.opencl64; + +public class OpenCLCommandQueueProperties extends OpenCLProperties{ + + /** + * + */ + private static final long serialVersionUID = 1L; + +} diff --git a/src/org/kne/opencl64/OpenCLContext.java b/src/org/kne/opencl64/OpenCLContext.java new file mode 100644 index 0000000..b9a308c --- /dev/null +++ b/src/org/kne/opencl64/OpenCLContext.java @@ -0,0 +1,130 @@ +package org.kne.opencl64; + + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.ref.Cleaner; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import club.doki7.ffm.ptr.IntPtr; +import club.doki7.opencl.CLFunctionTypes.Ipfn_notify_0; +import club.doki7.opencl.handle.CLContext; +import club.doki7.opencl.handle.CLDeviceId; + + +public class OpenCLContext { + + private CLContext cl_context; + private List devices; + private OpenCLContextProperties properties; + private OpenCLPlatform platform; + + + + public OpenCLPlatform getPlatform() { + return platform; + } + + protected CLContext getCl_context() { + return cl_context; + } + + public List getDevices() { + return devices; + } + + public OpenCLContextProperties getProperties() { + return properties; + } + + private static final Cleaner clr=Cleaner.create(); + + private class CallbackImpl implements Ipfn_notify_0{ + + private OpenCLCreateContextCallback callback; + private Object userData; + + public CallbackImpl(OpenCLCreateContextCallback callback, Object userData) { + this.callback=callback; + this.userData=userData; + } + + @Override + public void invoke( MemorySegment p0, MemorySegment p1, MemorySegment p2, + MemorySegment p3) { + if(callback!=null) + callback.function(p0.getString(0, Charset.forName("utf-8")), p1.getAtIndex(OfLong.JAVA_LONG, 0) , p2.getAtIndex(OfLong.JAVA_LONG, 0), userData); + } + + } + + public OpenCLContext(OpenCLContextProperties properties,List devices,OpenCLCreateContextCallback callback,Object userData) { + if(devices==null) { + throw new IllegalArgumentException("ContextPlatform in properties is null!"); + } + devices=Collections.unmodifiableList( new ArrayList(devices)); + + this.devices= devices; + int size=devices.size(); + CLDeviceId.Ptr devs=CLDeviceId.Ptr.allocate(Arena.ofAuto(),size); + for (int i = 0; i < size; i++) { + devs.write(i, devices.get(i).getCl_device_id()); + } + + this.properties=properties; + this.platform=properties.getContextPlatform(); + MemorySegment userDataSegment=MemorySegment.NULL; + if(userData instanceof Long) { + userDataSegment=Arena.ofAuto().allocate(8); + userDataSegment.setAtIndex(OfLong.JAVA_LONG, 0, (Long) userData); + } + IntPtr errcode=IntPtr.allocate(Arena.ofAuto()); + cl_context=OpenCLPlatform.opencl.createContext(properties.toPtrProperties(), size,devs , new CallbackImpl(callback,userData),userDataSegment, errcode); + CLUtils.checkResult(errcode); + releaser=new OpenCLContextReleaser(cl_context); + clr.register(this, releaser); + } + public OpenCLContext(OpenCLPlatform platform,List devices,OpenCLCreateContextCallback callback,Object userData) { + + this(createDefaultProperties(platform),devices,callback,userData); + } + public OpenCLContext(OpenCLPlatform platform,List devices) { + this(platform,devices,null,null); + } + + public OpenCLContext(OpenCLPlatform platform, OpenCLDevice device) { + this(platform,List.of( device)); + } + private static OpenCLContextProperties createDefaultProperties(OpenCLPlatform platform) { + OpenCLContextProperties contextProperties = new OpenCLContextProperties(); + contextProperties.setContextPlatform( platform); + return contextProperties; + } + + private OpenCLContextReleaser releaser; + + public void close() { + + releaser.run(); + } + public boolean isClosed() { + return releaser.isReleased(); + } +} +class OpenCLContextReleaser extends Releaser{ + + public OpenCLContextReleaser(CLContext resource) { + super(resource); + } + + @Override + protected void release(CLContext resource) { + int errcode=OpenCLPlatform.opencl.releaseContext(resource); + CLUtils.checkResult(errcode); + } + +} \ No newline at end of file diff --git a/src/org/kne/opencl64/OpenCLContextProperties.java b/src/org/kne/opencl64/OpenCLContextProperties.java new file mode 100644 index 0000000..c2ab5d3 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLContextProperties.java @@ -0,0 +1,18 @@ +package org.kne.opencl64; +import club.doki7.opencl.CLConstants; +public class OpenCLContextProperties extends OpenCLProperties{ + + /** + * + */ + private static final long serialVersionUID = 1L; + public void setContextPlatform(OpenCLPlatform platform) { + put((long) CLConstants. CONTEXT_PLATFORM,platform); + } + + public OpenCLPlatform getContextPlatform() { + return (OpenCLPlatform) get((long) CLConstants.CONTEXT_PLATFORM); + } + + +} diff --git a/src/org/kne/opencl64/OpenCLCreateContextCallback.java b/src/org/kne/opencl64/OpenCLCreateContextCallback.java new file mode 100644 index 0000000..6a6a2c8 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLCreateContextCallback.java @@ -0,0 +1,5 @@ +package org.kne.opencl64; + +public interface OpenCLCreateContextCallback { + void function(String errinfo, long l, long cb, Object user_data); +} diff --git a/src/org/kne/opencl64/OpenCLDevice.java b/src/org/kne/opencl64/OpenCLDevice.java new file mode 100644 index 0000000..fc65253 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLDevice.java @@ -0,0 +1,326 @@ +package org.kne.opencl64; + + +import java.io.Closeable; +import java.io.IOException; +import java.lang.ref.Cleaner; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import club.doki7.opencl.CLConstants; +import club.doki7.opencl.handle.CLDeviceId; + +public class OpenCLDevice { + private OpenCLPlatform platform; + private CLDeviceId cl_device_id; + + private static final Cleaner clr=Cleaner.create(); + + + public static List getAllDevices() { + List devs = new ArrayList<>(); + List ocp = OpenCLPlatform.getOpenCLPlatforms(); + for (OpenCLPlatform openCLPlatform : ocp) { + List devices = openCLPlatform.getOpenCLDevices(); + for (OpenCLDevice openCLDevice : devices) { + devs.add(openCLDevice); + } + } + return devs; + } + + + public static List getAllGPU() { + List gpus = new ArrayList<>(); + List ocp = OpenCLPlatform.getOpenCLPlatforms(); + for (OpenCLPlatform openCLPlatform : ocp) { + List devices = openCLPlatform.getOpenCLDevices(); + for (OpenCLDevice openCLDevice : devices) { + if(openCLDevice.getDeviceType()==DeviceType.GPU) + gpus.add(openCLDevice); + } + } + return gpus; + } + + public static List getAllCPU() { + List cpus = new ArrayList<>(); + List ocp = OpenCLPlatform.getOpenCLPlatforms(); + for (OpenCLPlatform openCLPlatform : ocp) { + List devices = openCLPlatform.getOpenCLDevices(); + for (OpenCLDevice openCLDevice : devices) { + if(openCLDevice.getDeviceType()==DeviceType.CPU) + cpus.add(openCLDevice); + } + } + return cpus; + } + + protected OpenCLDevice(OpenCLPlatform platform,CLDeviceId cl_device_id) { + this.platform=platform; + this.cl_device_id=cl_device_id; + this.releaser=new OpenCLDeviceReleaser(cl_device_id); + clr.register(this, releaser); + } + + public OpenCLPlatform getPlatform() { + return platform; + } + + public CLDeviceId getCl_device_id() { + return cl_device_id; + } + + public String getName() { + String deviceName = OpenCLPlatform.openclUtils. getString(cl_device_id, CLConstants. DEVICE_NAME); + return deviceName; + } + + public String getVendor() { + String deviceVendor = OpenCLPlatform.openclUtils.getString(cl_device_id, CLConstants.DEVICE_VENDOR); + return deviceVendor; + } + + public String getDriverVersion() { + String driverVersion = OpenCLPlatform.openclUtils.getString(cl_device_id, CLConstants.DRIVER_VERSION); + return driverVersion; + } + + public DeviceType getDeviceType() { + long deviceType = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_TYPE); + if( (deviceType & CLConstants.DEVICE_TYPE_CPU) != 0) + return DeviceType.CPU; + if( (deviceType & CLConstants.DEVICE_TYPE_GPU) != 0) + return DeviceType.GPU; + if( (deviceType & CLConstants.DEVICE_TYPE_ACCELERATOR) != 0) + return DeviceType.ACCELERATOR; + if( (deviceType & CLConstants.DEVICE_TYPE_DEFAULT) != 0) + return DeviceType.DEFAULT; + return DeviceType.UNKNOWN; + } + + public int getMaxComputeUnits() { + int maxComputeUnits = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_MAX_COMPUTE_UNITS); + return maxComputeUnits; + } + + public long getMaxWorkItemDimensions(){ + long maxWorkItemDimensions = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_MAX_WORK_ITEM_DIMENSIONS); + return maxWorkItemDimensions; + } + + public long[] getWorkItemSizes() { + long maxWorkItemSizes[] = OpenCLPlatform.openclUtils.getSizes(cl_device_id, CLConstants.DEVICE_MAX_WORK_ITEM_SIZES, (int) getMaxWorkItemDimensions()); + return maxWorkItemSizes; + } + public long getMaxWorkGroupSize() { + long maxWorkGroupSize = OpenCLPlatform.openclUtils.getSize(cl_device_id, CLConstants.DEVICE_MAX_WORK_GROUP_SIZE); + return maxWorkGroupSize; + } + + public long getMaxClockFrequency() { + long maxClockFrequency = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_MAX_CLOCK_FREQUENCY); + return maxClockFrequency; + } + + public int getAddressBits() { + int addressBits = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_ADDRESS_BITS); + return addressBits; + } + + public long getMaxMemAllocSize() { + long maxMemAllocSize = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_MAX_MEM_ALLOC_SIZE); + return maxMemAllocSize; + } + public long getGlobalMemSize() { + long globalMemSize = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_GLOBAL_MEM_SIZE); + return globalMemSize; + } + public boolean isErrorCorrectionSupport() { + int errorCorrectionSupport = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_ERROR_CORRECTION_SUPPORT); + return errorCorrectionSupport!=0; + } + public LocalMemType getLocalMemType() { + int localMemType = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_LOCAL_MEM_TYPE); + if(localMemType==1) { + return LocalMemType.LOCAL; + }else { + return LocalMemType.GLOBAL; + } + } + + public long getLocalMemSize() { + long localMemSize = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_LOCAL_MEM_SIZE); + return localMemSize; + } + public long getMaxConstantBufferSize() { + long maxConstantBufferSize = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_MAX_CONSTANT_BUFFER_SIZE); + return maxConstantBufferSize; + } + + public List getQueueProperties() { + long queueProperties = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_QUEUE_ON_HOST_PROPERTIES); + ArrayListqp=new ArrayList<>(); + if(( queueProperties & CLConstants.QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ) != 0) + qp.add(QueueProperty.QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE); + if(( queueProperties & CLConstants.QUEUE_PROFILING_ENABLE ) != 0) + qp.add(QueueProperty.QUEUE_PROFILING_ENABLE); + return Collections.unmodifiableList( qp); + } + public boolean isImageSupport(){ + int imageSupport = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_IMAGE_SUPPORT); + return imageSupport!=0; + } + + public int getMaxReadImageArgs() { + int maxReadImageArgs = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_MAX_READ_IMAGE_ARGS); + return maxReadImageArgs; + } + public int getMaxWriteImageArgs(){ + int maxWriteImageArgs = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_MAX_WRITE_IMAGE_ARGS); + return maxWriteImageArgs; + } + public List getSingleFpConfig(){ + long singleFpConfig = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_SINGLE_FP_CONFIG); + Listsfp=new ArrayList<>(); + + if ((singleFpConfig & CLConstants.FP_DENORM) != 0) sfp .add(FpConfig.FP_DENORM); + if ((singleFpConfig & CLConstants.FP_INF_NAN) != 0) sfp .add(FpConfig.FP_INF_NAN); + if ((singleFpConfig & CLConstants.FP_ROUND_TO_NEAREST) != 0) sfp .add(FpConfig.FP_ROUND_TO_NEAREST); + if ((singleFpConfig & CLConstants.FP_ROUND_TO_ZERO) != 0) sfp .add(FpConfig.FP_ROUND_TO_ZERO); + if ((singleFpConfig & CLConstants.FP_ROUND_TO_INF) != 0) sfp .add(FpConfig.FP_INF_NAN); + if ((singleFpConfig & CLConstants.FP_FMA) != 0) sfp .add(FpConfig.FP_FMA); + if ((singleFpConfig & CLConstants.FP_SOFT_FLOAT) != 0) sfp .add(FpConfig.FP_SOFT_FLOAT); + if ((singleFpConfig & CLConstants.FP_CORRECTLY_ROUNDED_DIVIDE_SQRT) != 0) sfp .add(FpConfig.FP_CORRECTLY_ROUNDED_DIVIDE_SQRT); + return Collections.unmodifiableList(sfp); + } + + public List getDoubleFpConfig(){ + long singleFpConfig = OpenCLPlatform.openclUtils.getLong(cl_device_id, CLConstants.DEVICE_DOUBLE_FP_CONFIG); + Listsfp=new ArrayList<>(); + + if ((singleFpConfig & CLConstants.FP_DENORM) != 0) sfp .add(FpConfig.FP_DENORM); + if ((singleFpConfig & CLConstants.FP_INF_NAN) != 0) sfp .add(FpConfig.FP_INF_NAN); + if ((singleFpConfig & CLConstants.FP_ROUND_TO_NEAREST) != 0) sfp .add(FpConfig.FP_ROUND_TO_NEAREST); + if ((singleFpConfig & CLConstants.FP_ROUND_TO_ZERO) != 0) sfp .add(FpConfig.FP_ROUND_TO_ZERO); + if ((singleFpConfig & CLConstants.FP_ROUND_TO_INF) != 0) sfp .add(FpConfig.FP_INF_NAN); + if ((singleFpConfig & CLConstants.FP_FMA) != 0) sfp .add(FpConfig.FP_FMA); + if ((singleFpConfig & CLConstants.FP_SOFT_FLOAT) != 0) sfp .add(FpConfig.FP_SOFT_FLOAT); + if ((singleFpConfig & CLConstants.FP_CORRECTLY_ROUNDED_DIVIDE_SQRT) != 0) sfp .add(FpConfig.FP_CORRECTLY_ROUNDED_DIVIDE_SQRT); + return Collections.unmodifiableList(sfp); + } + + public long getImage2dMaxWidth() { + long image2dMaxWidth = OpenCLPlatform.openclUtils.getSize(cl_device_id, CLConstants.DEVICE_IMAGE2D_MAX_WIDTH); + return image2dMaxWidth; + } + + public long getImage2dMaxHeight() { + long image2dMaxHeight = OpenCLPlatform.openclUtils.getSize(cl_device_id, CLConstants.DEVICE_IMAGE2D_MAX_HEIGHT); + return image2dMaxHeight; + } + public long getImage3dMaxWidth() { + long image3dMaxWidth = OpenCLPlatform.openclUtils.getSize(cl_device_id, CLConstants.DEVICE_IMAGE3D_MAX_WIDTH); + return image3dMaxWidth; + } + public long getImage3dMaxHeight() { + long image3dMaxHeight = OpenCLPlatform.openclUtils.getSize(cl_device_id, CLConstants.DEVICE_IMAGE3D_MAX_HEIGHT); + return image3dMaxHeight; + } + public long getImage3dMaxDepth() { + long image3dMaxDepth = OpenCLPlatform.openclUtils. getSize(cl_device_id, CLConstants.DEVICE_IMAGE3D_MAX_DEPTH); + return image3dMaxDepth; + } + public int getPreferredVectorWidthChar() { + int preferredVectorWidthChar = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_CHAR); + return preferredVectorWidthChar; + } + public int getPreferredVectorWidthShort() { + int preferredVectorWidthShort = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_SHORT); + return preferredVectorWidthShort; + } + public int getPreferredVectorWidthInt() { + int preferredVectorWidthInt = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_INT); + return preferredVectorWidthInt; + } + public int getPreferredVectorWidthLong() { + int preferredVectorWidthLong = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_LONG); + return preferredVectorWidthLong; + } + public int getPreferredVectorWidthFloat() { + int preferredVectorWidthFloat = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT); + return preferredVectorWidthFloat; + } + public int getPreferredVectorWidthDouble() { + int preferredVectorWidthDouble = OpenCLPlatform.openclUtils.getInt(cl_device_id, CLConstants.DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE); + return preferredVectorWidthDouble; + } + + @Override + public String toString() { + return String.format( + "OpenCLDevice[%s | %s | %s | CUs=%d | Freq=%dMHz | Global=%.2fGB | MaxAlloc=%.2fGB | Local=%.2fKB | MaxWG=%d | MaxDim=%d | ECC=%s]", + getName(), + getVendor().replace(" Corporation", ""), + getDeviceType(), + getMaxComputeUnits(), + getMaxClockFrequency(), + getGlobalMemSize() / (1024.0 * 1024.0 * 1024.0), + getMaxMemAllocSize() / (1024.0 * 1024.0 * 1024.0), + getLocalMemSize() / 1024.0, + getMaxWorkGroupSize(), + getMaxWorkItemDimensions(), + isErrorCorrectionSupport() ? "ON" : "OFF" + ); + } + + public String toStringFull() { + return "OpenCLDevice [getName()=" + getName() + ", getVendor()=" + getVendor() + ", getDriverVersion()=" + + getDriverVersion() + ", getDeviceType()=" + getDeviceType() + ", getMaxComputeUnits()=" + + getMaxComputeUnits() + ", getMaxWorkItemDimensions()=" + getMaxWorkItemDimensions() + + ", getWorkItemSizes()=" + Arrays.toString(getWorkItemSizes()) + ", getMaxWorkGroupSize()=" + + getMaxWorkGroupSize() + ", getMaxClockFrequency()=" + getMaxClockFrequency() + ", getAddressBits()=" + + getAddressBits() + ", getMaxMemAllocSize()=" + getMaxMemAllocSize() + ", getGlobalMemSize()=" + + getGlobalMemSize() + ", isErrorCorrectionSupport()=" + isErrorCorrectionSupport() + + ", getLocalMemType()=" + getLocalMemType() + ", getLocalMemSize()=" + getLocalMemSize() + + ", getMaxConstantBufferSize()=" + getMaxConstantBufferSize() + ", getQueueProperties()=" + + getQueueProperties() + ", isImageSupport()=" + isImageSupport() + ", getMaxReadImageArgs()=" + + getMaxReadImageArgs() + ", getMaxWriteImageArgs()=" + getMaxWriteImageArgs() + + ", getSingleFpConfig()=" + getSingleFpConfig() + ", getDoubleFpConfig()=" + getDoubleFpConfig() + + ", getImage2dMaxWidth()=" + getImage2dMaxWidth() + ", getImage2dMaxHeight()=" + getImage2dMaxHeight() + + ", getImage3dMaxWidth()=" + getImage3dMaxWidth() + ", getImage3dMaxHeight()=" + getImage3dMaxHeight() + + ", getImage3dMaxDepth()=" + getImage3dMaxDepth() + ", getPreferredVectorWidthChar()=" + + getPreferredVectorWidthChar() + ", getPreferredVectorWidthShort()=" + getPreferredVectorWidthShort() + + ", getPreferredVectorWidthInt()=" + getPreferredVectorWidthInt() + ", getPreferredVectorWidthLong()=" + + getPreferredVectorWidthLong() + ", getPreferredVectorWidthFloat()=" + getPreferredVectorWidthFloat() + + ", getPreferredVectorWidthDouble()=" + getPreferredVectorWidthDouble() + "]"; + } + + private OpenCLDeviceReleaser releaser; + + public void close() { + releaser.run(); + } + + + public boolean isClosed() { + return releaser.isReleased(); + } + + +} +class OpenCLDeviceReleaser extends Releaser{ + + public OpenCLDeviceReleaser(CLDeviceId resource) { + super(resource); + } + + @Override + protected void release(CLDeviceId resource) { + int errcode=OpenCLPlatform.opencl.releaseDevice(resource); + CLUtils.checkResult(errcode); + } +} \ No newline at end of file diff --git a/src/org/kne/opencl64/OpenCLException.java b/src/org/kne/opencl64/OpenCLException.java new file mode 100644 index 0000000..0764971 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLException.java @@ -0,0 +1,20 @@ +package org.kne.opencl64; + +public class OpenCLException extends RuntimeException { + + private int errorcode; + + public OpenCLException(String message,int errorcode) { + super(message); + this.errorcode=errorcode; + } + + public OpenCLException(Throwable cause) { + super(cause); + } + + public int getErrorcode() { + return errorcode; + } + +} diff --git a/src/org/kne/opencl64/OpenCLKernel.java b/src/org/kne/opencl64/OpenCLKernel.java new file mode 100644 index 0000000..fcee0ed --- /dev/null +++ b/src/org/kne/opencl64/OpenCLKernel.java @@ -0,0 +1,176 @@ +package org.kne.opencl64; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.lang.ref.Cleaner; + +import club.doki7.ffm.ptr.BytePtr; +import club.doki7.ffm.ptr.DoublePtr; +import club.doki7.ffm.ptr.FloatPtr; +import club.doki7.ffm.ptr.IntPtr; +import club.doki7.ffm.ptr.LongPtr; +import club.doki7.ffm.ptr.PointerPtr; +import club.doki7.ffm.ptr.ShortPtr; +import club.doki7.opencl.handle.CLKernel; +public class OpenCLKernel { + private OpenCLProgram program; + private CLKernel cl_kernel; + private String name; + private int argindex=0; + + private static final Cleaner clr=Cleaner.create(); + + + public OpenCLProgram getProgram() { + return program; + } + + public CLKernel getCl_kernel() { + return cl_kernel; + } + + public String getName() { + return name; + } + + public OpenCLKernel(OpenCLProgram program,String name) { + this.program=program; + this.name=name; + IntPtr errcode=IntPtr.allocate(Arena.ofAuto()); + cl_kernel=OpenCLPlatform.opencl.createKernel(program.getCl_program(), BytePtr.allocateString(Arena.ofAuto(), name), errcode); + CLUtils.checkResult(errcode); + regCleaner(); + } + private void regCleaner() { + releaser=new OpenCLKernelReleaser(cl_kernel); + clr.register(this, releaser); + } + + protected OpenCLKernel(OpenCLProgram program,CLKernel cl_kernel) { + this.program=program; + this.cl_kernel=cl_kernel; + } + public void resetArgIndex() { + argindex=0; + } + + public OpenCLKernel putArg(OpenCLMemory omem) { + return setArg(argindex++,omem); + } + public OpenCLKernel putArg(int val) { + return setArg(argindex++,val); + } + public OpenCLKernel putArg(long val) { + return setArg(argindex++,val); + } + public OpenCLKernel putArg(float val) { + return setArg(argindex++,val); + } + public OpenCLKernel putArg(double val) { + return setArg(argindex++,val); + } + public OpenCLKernel putArg(short val) { + return setArg(argindex++,val); + } + public OpenCLKernel putArg(byte val) { + return setArg(argindex++,val); + } + public OpenCLKernel putLocalMemoryArg(long length) { + return setLocalMemoryArg(argindex++,length); + } + + private OpenCLKernel setLocalMemoryArg(int index, long length) { + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,length, MemorySegment.NULL); + CLUtils.checkResult(errcode); + return this; + } + + public OpenCLKernel setArg(int index,OpenCLMemory omem) { + PointerPtr pptr=PointerPtr.allocate(Arena.ofAuto()); + pptr.write(omem.getCl_mem()); + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,pptr.segment().byteSize(), pptr.segment()); + CLUtils.checkResult(errcode); + return this; + } + + public OpenCLKernel setArg(int index,int val) { + IntPtr pptr=IntPtr.allocate(Arena.ofAuto()); + pptr.write(val); + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,pptr.segment().byteSize(), pptr.segment()); + CLUtils.checkResult(errcode); + return this; + } + + public OpenCLKernel setArg(int index,long val) { + LongPtr pptr=LongPtr.allocate(Arena.ofAuto()); + pptr.write(val); + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,pptr.segment().byteSize(), pptr.segment()); + CLUtils.checkResult(errcode); + return this; + } + + public OpenCLKernel setArg(int index,float val) { + FloatPtr pptr=FloatPtr.allocate(Arena.ofAuto()); + pptr.write(val); + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,pptr.segment().byteSize(), pptr.segment()); + CLUtils.checkResult(errcode); + return this; + } + + public OpenCLKernel setArg(int index,double val) { + DoublePtr pptr=DoublePtr.allocate(Arena.ofAuto()); + pptr.write(val); + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,pptr.segment().byteSize(), pptr.segment()); + CLUtils.checkResult(errcode); + return this; + } + + public OpenCLKernel setArg(int index,short val) { + ShortPtr pptr=ShortPtr.allocate(Arena.ofAuto()); + pptr.write(val); + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,pptr.segment().byteSize(), pptr.segment()); + CLUtils.checkResult(errcode); + return this; + } + + public OpenCLKernel setArg(int index,byte val) { + BytePtr pptr=BytePtr.allocate(Arena.ofAuto()); + pptr.write(val); + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,pptr.segment().byteSize(), pptr.segment()); + CLUtils.checkResult(errcode); + return this; + } + + /*public OpenCLKernel setArg(int index,boolean val) { + PointerPtr pptr=PointerPtr.allocate(Arena.ofAuto()); + pptr.write(val); + int errcode=OpenCLPlatform.opencl.setKernelArg(cl_kernel, index,ValueLayout.ADDRESS.byteSize(), pptr.segment()); + CLUtils.checkResult(errcode); + return this; + }*/ + + private OpenCLKernelReleaser releaser; + public void close() { + releaser.run(); + } + + public boolean isClosed() { + return releaser.isReleased(); + } + + +} +class OpenCLKernelReleaser extends Releaser{ + + public OpenCLKernelReleaser(CLKernel resource) { + super(resource); + } + + @Override + protected void release(CLKernel resource) { + int errcode=OpenCLPlatform.opencl.releaseKernel(resource); + CLUtils.checkResult(errcode); + } + +} diff --git a/src/org/kne/opencl64/OpenCLMapFlag.java b/src/org/kne/opencl64/OpenCLMapFlag.java new file mode 100644 index 0000000..01d9d2d --- /dev/null +++ b/src/org/kne/opencl64/OpenCLMapFlag.java @@ -0,0 +1,13 @@ +package org.kne.opencl64; + +import club.doki7.opencl.CLConstants; + +public enum OpenCLMapFlag { + CL_MAP_READ(CLConstants.MAP_READ),CL_MAP_WRITE(CLConstants.MAP_WRITE),CL_MAP_WRITE_INVALIDATE_REGION(CLConstants.MAP_WRITE_INVALIDATE_REGION); + + public final int flags; + + private OpenCLMapFlag(int flags) { + this.flags=flags; + } +} diff --git a/src/org/kne/opencl64/OpenCLMemReleaseCallback.java b/src/org/kne/opencl64/OpenCLMemReleaseCallback.java new file mode 100644 index 0000000..ec48927 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLMemReleaseCallback.java @@ -0,0 +1,5 @@ +package org.kne.opencl64; + +public interface OpenCLMemReleaseCallback { + void function(OpenCLMemory memobj, Object user_data); +} diff --git a/src/org/kne/opencl64/OpenCLMemory.java b/src/org/kne/opencl64/OpenCLMemory.java new file mode 100644 index 0000000..57f2b8e --- /dev/null +++ b/src/org/kne/opencl64/OpenCLMemory.java @@ -0,0 +1,173 @@ +package org.kne.opencl64; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.ref.Cleaner; + +import club.doki7.ffm.ptr.IntPtr; +import club.doki7.opencl.CL; +import club.doki7.opencl.CLConstants; +import club.doki7.opencl.CLFunctionTypes.Ipfn_notify_3; +import club.doki7.opencl.handle.CLMem; + +public class OpenCLMemory{ + private CLMem cl_mem; + private OpenCLContext context; + private OpenCLMemoryRWFlag rwflag; + private OpenCLMemoryCopyType copytype; + private long size; + + private static final Cleaner clr=Cleaner.create(); + + public OpenCLMemoryRWFlag getRwflag() { + return rwflag; + } + public OpenCLMemoryCopyType getCopytype() { + return copytype; + } + public long getSize() { + return size; + } + + public CLMem getCl_mem() { + return cl_mem; + } + public OpenCLContext getContext() { + return context; + } + protected OpenCLMemory(OpenCLContext context,long memflags,long size,MemorySegment initData) { + this.context=context; + this.size=size; + if(initData==null) + initData=MemorySegment.NULL; + IntPtr errcode=IntPtr.allocate(Arena.ofAuto()); + cl_mem = OpenCLPlatform.opencl.createBuffer(context.getCl_context(), memflags, size, initData, errcode); + CLUtils.checkResult(errcode); + regCleaner(); + } + private void regCleaner() { + releaser=new OpenCLMemoryReleaser(cl_mem); + clr.register(this, releaser); + } + public OpenCLMemory(OpenCLContext context,OpenCLMemoryRWFlag rwflag,OpenCLMemoryCopyType copytype,long size,MemorySegment initData) { + this.rwflag=rwflag; + this.copytype=copytype; + this.context=context; + this.size=size; + if(initData==null) + initData=MemorySegment.NULL; + IntPtr errcode=IntPtr.allocate(Arena.ofAuto()); + long flag=rwflag.flagValue; + if(initData!=null) { + flag|=(copytype==null?0:copytype.flagValue); + } + cl_mem = OpenCLPlatform.opencl.createBuffer(context.getCl_context(), flag, size, initData, errcode); + CLUtils.checkResult(errcode); + regCleaner(); + } + public OpenCLMemory(OpenCLContext context,long size) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,null,size,null); + } + /*public OpenCLMemory(OpenCLContext context,byte[]initData) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,OpenCLMemoryCopyType.COPY_HOST_PTR,Sizeof.cl_char*initData.length,Pointer.to(initData)); + } + public OpenCLMemory(OpenCLContext context,short[]initData) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,OpenCLMemoryCopyType.COPY_HOST_PTR,Sizeof.cl_short*initData.length,Pointer.to(initData)); + } + public OpenCLMemory(OpenCLContext context,char[]initData) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,OpenCLMemoryCopyType.COPY_HOST_PTR,Sizeof.cl_char2*initData.length,Pointer.to(initData)); + } + public OpenCLMemory(OpenCLContext context,int[]initData) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,OpenCLMemoryCopyType.COPY_HOST_PTR,Sizeof.cl_int*initData.length,Pointer.to(initData)); + } + public OpenCLMemory(OpenCLContext context,long[]initData) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,OpenCLMemoryCopyType.COPY_HOST_PTR,Sizeof.cl_long*initData.length,Pointer.to(initData)); + } + public OpenCLMemory(OpenCLContext context,float[]initData) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,OpenCLMemoryCopyType.COPY_HOST_PTR,Sizeof.cl_float*initData.length,Pointer.to(initData)); + } + public OpenCLMemory(OpenCLContext context,double[]initData) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,OpenCLMemoryCopyType.COPY_HOST_PTR,Sizeof.cl_double*initData.length,Pointer.to(initData)); + } + public OpenCLMemory(OpenCLContext context,Buffer initData) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,OpenCLMemoryCopyType.COPY_HOST_PTR,initData.capacity()*getBufferUnitSize(initData) ,Pointer.to(initData)); + }*/ + public OpenCLMemory(OpenCLContext context,MemorySegment initData,OpenCLMemoryCopyType copyType) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,copyType,initData.byteSize() ,initData); + } + public OpenCLMemory(OpenCLContext context,MemorySegment initData) { + this(context,initData,OpenCLMemoryCopyType.COPY_HOST_PTR); + } + + public OpenCLMemory(OpenCLContext context, OpenCLMemoryCopyType copyHostPtr, long size) { + this(context,OpenCLMemoryRWFlag.READ_WRITE,copyHostPtr,size,null); + } + + + public long byteSize() { + MemorySegment ms= Arena.ofAuto().allocate(8); + OpenCLPlatform.opencl.getMemObjectInfo(cl_mem, CLConstants.MEM_SIZE, 8, ms, null); + return ms.getAtIndex(OfLong.JAVA_LONG, 0); + } + + public long address() { + return cl_mem.segment().address(); + } + + + + private class CallbackImpl implements Ipfn_notify_3{ + + private OpenCLMemReleaseCallback callback; + private Object userData; + + public CallbackImpl(OpenCLMemReleaseCallback callback, Object userData) { + this.callback=callback; + this.userData=userData; + } + + @Override + public void invoke(MemorySegment p0, MemorySegment p1) { + if(callback!=null) + callback.function(OpenCLMemory.this,userData); + } + + } + public void setReleaseCallback(OpenCLMemReleaseCallback callback,Object userData) { + MemorySegment userDataSegment=MemorySegment.NULL; + if(userData instanceof Long) { + userDataSegment=Arena.ofAuto().allocate(8); + userDataSegment.setAtIndex(OfLong.JAVA_LONG, 0, (Long) userData); + } + int errcode=OpenCLPlatform.opencl.setMemObjectDestructorCallback(cl_mem, + new CallbackImpl(callback,userData), + userDataSegment); + CLUtils.checkResult(errcode); + } + + private OpenCLMemoryReleaser releaser; + public void close() { + releaser.run(); + } + + public boolean isClosed() { + return releaser.isReleased(); + } +} +class OpenCLMemoryReleaser extends Releaser implements Runnable{ + + public OpenCLMemoryReleaser(CLMem resource) { + super(resource); + } + + @Override + protected void release(CLMem resource) { + int errcode=OpenCLPlatform.opencl.releaseMemObject(resource); + CLUtils.checkResult(errcode); + + } + + + +} diff --git a/src/org/kne/opencl64/OpenCLMemoryCopyType.java b/src/org/kne/opencl64/OpenCLMemoryCopyType.java new file mode 100644 index 0000000..d4620c6 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLMemoryCopyType.java @@ -0,0 +1,11 @@ +package org.kne.opencl64; +import club.doki7.opencl.CLConstants; +public enum OpenCLMemoryCopyType { + USE_HOST_PTR(CLConstants. MEM_USE_HOST_PTR), + ALLOC_HOST_PTR(CLConstants. MEM_ALLOC_HOST_PTR), + COPY_HOST_PTR(CLConstants. MEM_COPY_HOST_PTR); + public final long flagValue; + private OpenCLMemoryCopyType(long flag) { + this.flagValue=flag; + } +} diff --git a/src/org/kne/opencl64/OpenCLMemoryRWFlag.java b/src/org/kne/opencl64/OpenCLMemoryRWFlag.java new file mode 100644 index 0000000..7aaf4e5 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLMemoryRWFlag.java @@ -0,0 +1,11 @@ +package org.kne.opencl64; +import club.doki7.opencl.CLConstants; +public enum OpenCLMemoryRWFlag { + READ_ONLY(CLConstants.MEM_READ_ONLY), + WRITE_ONLY(CLConstants.MEM_WRITE_ONLY), + READ_WRITE(CLConstants.MEM_READ_WRITE); + public final long flagValue; + private OpenCLMemoryRWFlag(long flag) { + this.flagValue=flag; + } +} diff --git a/src/org/kne/opencl64/OpenCLPlatform.java b/src/org/kne/opencl64/OpenCLPlatform.java new file mode 100644 index 0000000..e65d21f --- /dev/null +++ b/src/org/kne/opencl64/OpenCLPlatform.java @@ -0,0 +1,88 @@ +package org.kne.opencl64; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout.OfByte; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; + +import club.doki7.ffm.library.ILibraryLoader; +import club.doki7.ffm.library.JavaSystemLibrary; +import club.doki7.ffm.library.WindowsLibrary; +import club.doki7.ffm.ptr.IntPtr; +import club.doki7.opencl.CL; +import club.doki7.opencl.CLConstants; +import club.doki7.opencl.handle.CLDeviceId; +import club.doki7.opencl.handle.CLPlatformId; + +public class OpenCLPlatform { + static CL opencl=new CL(ILibraryLoader.platformLoader().loadLibrary("OpenCL")); + static CLUtils openclUtils=new CLUtils(opencl); + + private CLPlatformId cl_platform_id; + + protected CLPlatformId getCl_platform_id() { + return cl_platform_id; + } + + protected OpenCLPlatform(CLPlatformId cl_platform_id) { + this.cl_platform_id=cl_platform_id; + } + + public static List getOpenCLPlatforms() { + // int numPlatforms[] = new int[1]; + IntPtr iptr=IntPtr.allocate(Arena.ofAuto()); + int errcode =opencl. getPlatformIDs(0, null, iptr); + CLUtils.checkResult(errcode); + //System.out.println("Number of platforms: "+numPlatforms[0]); + + // Obtain the platform IDs + CLPlatformId.Ptr platforms = CLPlatformId.Ptr.allocate(Arena.ofAuto(), iptr.read()); + errcode= opencl.getPlatformIDs(iptr.read(), platforms, iptr); + CLUtils.checkResult(errcode); + List plats=new ArrayList<>(iptr.read()); + for (int i=0;i getOpenCLDevices() { + IntPtr numDevices = IntPtr.allocate(Arena.ofAuto()); + int errcode=opencl.getDeviceIDs(cl_platform_id, CLConstants.DEVICE_TYPE_ALL, 0, null, numDevices); + if(errcode==CLConstants. DEVICE_NOT_FOUND) { + return Collections.unmodifiableList( new ArrayList<>()); + } + CLUtils.checkResult(errcode); + CLDeviceId.Ptr devicesArray = CLDeviceId.Ptr.allocate(Arena.ofAuto(),numDevices.read()); + errcode=opencl.getDeviceIDs(cl_platform_id, CLConstants.DEVICE_TYPE_ALL, numDevices.read(), devicesArray, null); + CLUtils.checkResult(errcode); + List devs=new ArrayList<>(numDevices.read()); + for (int i = 0; i < numDevices.read(); i++) { + devs.add(new OpenCLDevice(this, devicesArray.read(i))); + } + return Collections.unmodifiableList(devs); + } + + + + @Override + public String toString() { + return "OpenCLPlatform [getName()=" + getName() + ", getVersion()=" + getVersion() + "]"; + } + + +} diff --git a/src/org/kne/opencl64/OpenCLProgram.java b/src/org/kne/opencl64/OpenCLProgram.java new file mode 100644 index 0000000..8f188cf --- /dev/null +++ b/src/org/kne/opencl64/OpenCLProgram.java @@ -0,0 +1,173 @@ +package org.kne.opencl64; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout.OfLong; +import java.lang.ref.Cleaner; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; + + +import club.doki7.ffm.ptr.BytePtr; +import club.doki7.ffm.ptr.IntPtr; +import club.doki7.ffm.ptr.PointerPtr; +import club.doki7.opencl.CLConstants; +import club.doki7.opencl.CLFunctionTypes.Ipfn_notify_5; +import club.doki7.opencl.handle.CLDeviceId; +import club.doki7.opencl.handle.CLDeviceId.Ptr; +import club.doki7.opencl.handle.CLKernel; +import club.doki7.opencl.handle.CLProgram; + +public class OpenCLProgram{ + private CLProgram cl_program; + private OpenCLContext context; + + private static final Cleaner clr=Cleaner.create(); + { + clr.register(this, ()->{ + close(); + }); + } + + + + public CLProgram getCl_program() { + return cl_program; + } + + public OpenCLContext getContext() { + return context; + } + + public OpenCLProgram(OpenCLContext context,String[]sources) { + this.context=context; + PointerPtr ptrs=PointerPtr.allocateStrings(Arena.ofAuto(), sources); + IntPtr errcode=IntPtr.allocate(Arena.ofAuto()); + cl_program = OpenCLPlatform.opencl.createProgramWithSource(context.getCl_context(), + sources.length, ptrs, null, errcode); + CLUtils.checkResult(errcode); + } + public OpenCLProgram(OpenCLContext context,String source) { + this(context,new String[] {source}); + } + public OpenCLProgram(OpenCLContext context,InputStream sourceinput) throws IOException { + this(context,readInput(sourceinput)); + } + private static String readInput(InputStream sourceinput) throws IOException { + try + { + return new String( sourceinput.readAllBytes(),Charset.forName("utf-8")); + } + finally + { + if(sourceinput!=null) + sourceinput.close(); + } + } + + private class CallbackImpl implements Ipfn_notify_5{ + + private OpenCLBuildProgramCallback callback; + private Object userData; + + public CallbackImpl(OpenCLBuildProgramCallback callback, Object userData) { + this.callback=callback; + this.userData=userData; + } + + @Override + public void invoke(MemorySegment p0, MemorySegment p1) { + if(callback!=null) + callback.function(OpenCLProgram.this, userData); + } + + } + + public void buildProgram(Listdevices,String options,OpenCLBuildProgramCallback callback,Object userData) { + if(devices==null) { + int errcode =OpenCLPlatform.opencl.buildProgram(cl_program, 0, null, null, new CallbackImpl( callback,userData), MemorySegment.NULL); + CLUtils.checkResult(this,null,errcode); + }else { + int size=devices.size(); + CLDeviceId.Ptr devid=CLDeviceId.Ptr.allocate(Arena.ofAuto(),size); + for (int i = 0; i < size; i++) { + CLDeviceId cid=devices.get(i).getCl_device_id(); + devid.write(i,cid); + } + MemorySegment userDataSegment=MemorySegment.NULL; + if(userData instanceof Long) { + userDataSegment=Arena.ofAuto().allocate(8); + userDataSegment.setAtIndex(OfLong.JAVA_LONG, 0, (Long) userData); + } + int errcode=OpenCLPlatform.opencl.buildProgram(cl_program, size, devid, options==null?null:BytePtr.allocateString(Arena.ofAuto(), options),new CallbackImpl( callback,userData), userDataSegment); + CLUtils.checkResult(this,devices, errcode); + } + + } + + + public void buildProgram(Listdevices) { + buildProgram(devices,null,null,null); + } + public void buildProgram(String options) { + buildProgram(null,options,null,null); + } + public void buildProgram() { + buildProgram((String)null); + } + + public OpenCLKernel createKernel(String name) { + return new OpenCLKernel(this, name); + } + + public List createKernels(){ + IntPtr nums=IntPtr.allocate(Arena.ofAuto()); + int errcode=OpenCLPlatform.opencl.createKernelsInProgram(cl_program, 0, null, nums); + CLUtils.checkResult(errcode); + CLKernel.Ptr kernels=CLKernel.Ptr.allocate(Arena.ofAuto(),nums.read()); + errcode=OpenCLPlatform.opencl.createKernelsInProgram(cl_program, nums.read(), kernels, nums); + CLUtils.checkResult(errcode); + List ret=new ArrayList<>(); + for (int i = 0; i < nums.read(); i++) { + ret.add(new OpenCLKernel(this, kernels.read(i)) ); + } + return ret; + } + + private OpenCLProgramReleaser releaser; + public void close() { + releaser.run(); + } + + public boolean isClosed() { + return releaser.isReleased(); + } + + public String getBuildLog(OpenCLDevice dev) { + PointerPtr iptr=PointerPtr.allocate(Arena.ofAuto(),8); + CLDeviceId device=dev.getCl_device_id(); + int resultr =OpenCLPlatform.opencl.getProgramBuildInfo(getCl_program(), device, CLConstants.PROGRAM_BUILD_LOG, 0, MemorySegment.NULL ,iptr); + CLUtils. checkResult(resultr); + MemorySegment ms=Arena.ofAuto().allocate(iptr.segment().get(OfLong.JAVA_LONG, 0)); + int resultrx =OpenCLPlatform.opencl.getProgramBuildInfo(getCl_program(), device, CLConstants.PROGRAM_BUILD_LOG, ms.byteSize(),ms ,iptr); + CLUtils.checkResult(resultrx); + String log=ms.getString(0, Charset.defaultCharset()); + return log; + } +} +class OpenCLProgramReleaser extends Releaser{ + + public OpenCLProgramReleaser(CLProgram resource) { + super(resource); + } + + @Override + protected void release(CLProgram resource) { + int errcode=OpenCLPlatform.opencl.releaseProgram(resource); + CLUtils.checkResult(errcode); + } + +} diff --git a/src/org/kne/opencl64/OpenCLProgramBuildException.java b/src/org/kne/opencl64/OpenCLProgramBuildException.java new file mode 100644 index 0000000..824df01 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLProgramBuildException.java @@ -0,0 +1,13 @@ +package org.kne.opencl64; + +public class OpenCLProgramBuildException extends OpenCLException { + + public OpenCLProgramBuildException(String message, int errorcode) { + super(message, errorcode); + } + + public OpenCLProgramBuildException(Throwable cause) { + super(cause); + } + +} diff --git a/src/org/kne/opencl64/OpenCLProperties.java b/src/org/kne/opencl64/OpenCLProperties.java new file mode 100644 index 0000000..630452e --- /dev/null +++ b/src/org/kne/opencl64/OpenCLProperties.java @@ -0,0 +1,54 @@ +package org.kne.opencl64; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout.OfLong; +import java.util.Arrays; +import java.util.HashMap; + +import club.doki7.ffm.ptr.LongPtr; +import club.doki7.ffm.ptr.PointerPtr; +import club.doki7.opencl.CLConstants; + +public class OpenCLProperties extends HashMap { + + /** + * + */ + private static final long serialVersionUID = 1L; + + protected PointerPtr toPtrProperties() { + //cl_context_properties ret=new cl_context_properties(); + PointerPtr ret=PointerPtr.allocate(Arena.ofAuto(),(size()+1)*2 ); + long off=0; + for (Entry entry : entrySet()) { + long key = entry.getKey(); + Object val = entry.getValue(); + if(key==CLConstants.CONTEXT_PLATFORM) { + ret.segment().setAtIndex(OfLong.JAVA_LONG, off, key); + ret.write(off+1, ((OpenCLPlatform)val).getCl_platform_id()); + //ret.addProperty(key, ((OpenCLPlatform)val).getCl_platform_id()); + } + off+=2; + } + //System.out.println(Arrays.toString( ret.segment().toArray(OfLong.JAVA_LONG))); + return ret; + } + + protected LongPtr toLongProperties() { + //cl_context_properties ret=new cl_context_properties(); + LongPtr ret=LongPtr.allocate(Arena.ofAuto(),(size()+1)*2 ); + long off=0; + for (Entry entry : entrySet()) { + long key = entry.getKey(); + Object val = entry.getValue(); + if(key==CLConstants.CONTEXT_PLATFORM) { + ret.write( off+0, key); + ret.write( off+1, ((OpenCLPlatform)val).getCl_platform_id().segment().address()); + //ret.addProperty(key, ((OpenCLPlatform)val).getCl_platform_id()); + } + off+=2; + } + return ret; + } +} diff --git a/src/org/kne/opencl64/OpenCLSVMMemory.java b/src/org/kne/opencl64/OpenCLSVMMemory.java new file mode 100644 index 0000000..9d21952 --- /dev/null +++ b/src/org/kne/opencl64/OpenCLSVMMemory.java @@ -0,0 +1,53 @@ +package org.kne.opencl64; + +import java.lang.foreign.MemorySegment; +import java.lang.ref.Cleaner; + +import club.doki7.opencl.CLConstants; + +public class OpenCLSVMMemory { + + private static final Cleaner clr=Cleaner.create(); + + private OpenCLContext context; + + private MemorySegment svmMemory; + + public OpenCLSVMMemory(OpenCLContext context,OpenCLMemoryRWFlag rwflag,boolean finebuffer,long size,int aligment) { + this.context=context; + svmMemory= OpenCLPlatform.opencl.SVMAlloc(context.getCl_context(), rwflag.flagValue|(finebuffer?CLConstants. MEM_SVM_FINE_GRAIN_BUFFER:0), size, aligment); + releaser=new OpenCLSVMMemoryReleaser(svmMemory); + clr.register(this, releaser); + } + public OpenCLSVMMemory(OpenCLContext context,OpenCLMemoryRWFlag rwflag,boolean finebuffer,long size) { + this(context,rwflag,finebuffer,size,0); + } + + public MemorySegment getSvmMemory() { + return svmMemory; + } + + + private OpenCLSVMMemoryReleaser releaser; + + public void close() { + releaser.run(); + } + + public boolean isClosed() { + return releaser.isReleased(); + } + + private class OpenCLSVMMemoryReleaser extends Releaser{ + + public OpenCLSVMMemoryReleaser(MemorySegment resource) { + super(resource); + } + + @Override + protected void release(MemorySegment resource) { + OpenCLPlatform.opencl.SVMFree(context.getCl_context(), svmMemory); + } + + } +} diff --git a/src/org/kne/opencl64/QueueProperty.java b/src/org/kne/opencl64/QueueProperty.java new file mode 100644 index 0000000..8d9f643 --- /dev/null +++ b/src/org/kne/opencl64/QueueProperty.java @@ -0,0 +1,5 @@ +package org.kne.opencl64; + +public enum QueueProperty { + QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,QUEUE_PROFILING_ENABLE; +} diff --git a/src/org/kne/opencl64/Releaser.java b/src/org/kne/opencl64/Releaser.java new file mode 100644 index 0000000..0ffcd21 --- /dev/null +++ b/src/org/kne/opencl64/Releaser.java @@ -0,0 +1,36 @@ +package org.kne.opencl64; + +import java.io.Closeable; +import java.util.concurrent.atomic.AtomicBoolean; + +public abstract class Releaser implements Runnable,Closeable,AutoCloseable{ + private AtomicBoolean released=new AtomicBoolean(); + private R resource; + public Releaser(R resource) { + super(); + this.resource = resource; + } + + public AtomicBoolean getReleased() { + return released; + } + + @Override + public void run() { + if(released.compareAndSet(false, true)) { + release(resource); + } + } + + public boolean isReleased() { + return released.get(); + } + + @Override + public void close() { + run(); + } + + protected abstract void release(R resource); + +} diff --git a/src/org/kne/opencl64/TestOpenCL64.java b/src/org/kne/opencl64/TestOpenCL64.java new file mode 100644 index 0000000..61cfd1a --- /dev/null +++ b/src/org/kne/opencl64/TestOpenCL64.java @@ -0,0 +1,97 @@ +package org.kne.opencl64; + +import java.lang.foreign.Arena; +import java.lang.foreign.MemorySegment; +import java.nio.ByteBuffer; +import java.util.List; + +public class TestOpenCL64 { + + public static void main(String[] args) throws InterruptedException { + stressTest(); + //bandwidthBenchmark(); + } + + private static void bandwidthBenchmark() { + List ocp=OpenCLPlatform.getOpenCLPlatforms(); + for (OpenCLPlatform openCLPlatform : ocp) { + System.out.println(openCLPlatform); + List devices= openCLPlatform.getOpenCLDevices(); + for (OpenCLDevice openCLDevice : devices) { + System.out.println(devices); + for(int i=0;i<10;i++) { + long length=1024L*1024L*1024L; + OpenCLContext cont=new OpenCLContext(openCLPlatform, openCLDevice); + OpenCLCommandQueue queue=new OpenCLCommandQueue(cont, openCLDevice); + OpenCLMemory ocma=new OpenCLMemory(cont,OpenCLMemoryCopyType.ALLOC_HOST_PTR,length); + OpenCLMemory ocmb=new OpenCLMemory(cont,OpenCLMemoryCopyType.ALLOC_HOST_PTR,length); + long start=System.nanoTime(); + queue.executeCopyBuffer(ocma, ocmb, 0, 0, length); + queue.finish(); + long time=System.nanoTime()-start; + System.out.println(time); + + long start2=System.nanoTime(); + MemorySegment mpa= queue.mapBuffer(ocma, false, OpenCLMapFlag.CL_MAP_READ, 0, length); + MemorySegment mpb=queue.mapBuffer(ocmb, true, OpenCLMapFlag.CL_MAP_WRITE, 0, length); + mpb.copyFrom(mpa); + queue.unmapBuffer(ocma, mpa, false); + queue.unmapBuffer(ocmb, mpb, true); + long time2=System.nanoTime()-start2; + System.out.println(time2); + + System.gc(); + } + } + } + } + + private static void stressTest() { + List ocp=OpenCLPlatform.getOpenCLPlatforms(); + for (OpenCLPlatform openCLPlatform : ocp) { + System.out.println(openCLPlatform); + List devices= openCLPlatform.getOpenCLDevices(); + for (OpenCLDevice openCLDevice : devices) { + new Thread(()->{ + long length=128; + OpenCLContext cont=new OpenCLContext(openCLPlatform, openCLDevice); + + + MemorySegment msa=Arena.ofAuto().allocate(length); + + + + OpenCLMemory ocma=new OpenCLMemory(cont,msa,OpenCLMemoryCopyType.USE_HOST_PTR); + + + MemorySegment msb=Arena.ofAuto().allocate(length); + OpenCLMemory ocmb=new OpenCLMemory(cont,msb,OpenCLMemoryCopyType.USE_HOST_PTR); + + MemorySegment msc=Arena.ofAuto().allocate(length); + OpenCLMemory ocmc=new OpenCLMemory(cont,msc,OpenCLMemoryCopyType.USE_HOST_PTR); + System.out.println("addr:"+msa.address()+" "+ocma.address()); + String programSource = + "__kernel void "+ + "sampleKernel(__global const float *a,"+ + " __global const float *b,"+ + " __global float *c)"+ + "{"+ + " printf(\"%lld\\n\",a); int gid = get_global_id(0);"+ + "for(int i=0;i<100;i++)"+ + " c[gid] = a[gid] + b[gid];"+ + "}"; + OpenCLProgram prog= new OpenCLProgram(cont, programSource); + prog.buildProgram(); + + OpenCLKernel kernel= prog.createKernel("sampleKernel"); + kernel.putArg(ocma).putArg(ocmb).putArg(ocmc); + OpenCLCommandQueue queue=new OpenCLCommandQueue(cont, openCLDevice); + queue.execute1DRangeKernel(kernel, 0, length/4); + queue.executeReadBuffer(ocmc,msc,true,0,0,msc.byteSize()); + queue.finish(); + //Thread.sleep(10000); + }).start(); + } + } + } +} diff --git a/src/org/kne/opencl64/concurrent/OpenCLContextThread.java b/src/org/kne/opencl64/concurrent/OpenCLContextThread.java new file mode 100644 index 0000000..8b2a720 --- /dev/null +++ b/src/org/kne/opencl64/concurrent/OpenCLContextThread.java @@ -0,0 +1,77 @@ +package org.kne.opencl64.concurrent; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.List; + +import org.kne.opencl64.OpenCLCommandQueue; +import org.kne.opencl64.OpenCLContext; +import org.kne.opencl64.OpenCLDevice; +import org.kne.opencl64.OpenCLProgram; + +public class OpenCLContextThread extends Thread { + private OpenCLDevice device; + private OpenCLContext context; + private OpenCLCommandQueue queue; + public OpenCLContextThread(OpenCLDevice device) { + super(); + this.device=device; + context=new OpenCLContext(device.getPlatform(), device); + queue=new OpenCLCommandQueue(context, device); + } + + public OpenCLContextThread(OpenCLDevice device,Runnable task) { + super(task); + this.device=device; + context=new OpenCLContext(device.getPlatform(), device); + queue=new OpenCLCommandQueue(context, device); + } + + + public OpenCLContextThread(OpenCLDevice device,OpenCLContext context) { + super(); + this.device=device; + this.context=context; + queue=new OpenCLCommandQueue(context, device); + } + + public OpenCLContextThread(OpenCLDevice device,OpenCLContext context,Runnable task) { + super(task); + this.device=device; + this.context=context; + queue=new OpenCLCommandQueue(context, device); + } + + private HashMapcache=new HashMap<>(); + public OpenCLProgram getProgram(String resourcepath) { + OpenCLProgram opg=cache.computeIfAbsent(resourcepath, (k)->{ + try { + String programSource = new String( OpenCLContextThread.class.getResourceAsStream(resourcepath).readAllBytes(),Charset.forName("utf8")); + OpenCLProgram prog= new OpenCLProgram(context, programSource); + prog.buildProgram(List.of(device)); + String log=prog.getBuildLog(device); + if(!log.isBlank()) { + System.out.print("编译日志:"+log ); + } + return prog; + } catch (IOException e) { + e.printStackTrace(); + } + return null; + }); + return opg; + } + + public OpenCLContext getOpenCLContext() { + return context; + } + public OpenCLCommandQueue getOpenCLCommandQueue() { + return queue; + } + + public OpenCLDevice getDevice() { + return device; + } + +} diff --git a/src/org/kne/opencl64/concurrent/OpenCLExecutors.java b/src/org/kne/opencl64/concurrent/OpenCLExecutors.java new file mode 100644 index 0000000..a608d95 --- /dev/null +++ b/src/org/kne/opencl64/concurrent/OpenCLExecutors.java @@ -0,0 +1,122 @@ +package org.kne.opencl64.concurrent; + +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.atomic.AtomicInteger; + +import org.kne.opencl64.OpenCLCommandQueue; +import org.kne.opencl64.OpenCLContext; +import org.kne.opencl64.OpenCLDevice; + +public class OpenCLExecutors { + + public static ExecutorService newFixedThreadPool(List devices, int threadsPerDevice) { + if (devices == null || devices.isEmpty()) { + throw new IllegalArgumentException("设备列表不能为空"); + } + if (threadsPerDevice <= 0) { + throw new IllegalArgumentException("每个设备的线程数必须大于 0"); + } + + int totalThreads = devices.size() * threadsPerDevice; + return (ThreadPoolExecutor) Executors.newFixedThreadPool( + totalThreads, + new ThreadFactory() { + private final AtomicInteger id = new AtomicInteger(0); + private OpenCLContext[] queue = new OpenCLContext[devices.size()]; + @Override + public Thread newThread(Runnable r) { + int idv = id.getAndIncrement(); + int devId = idv / threadsPerDevice; + int queueId = idv % threadsPerDevice; + OpenCLDevice device = devices.get(devId); + if (queue[devId] == null) { + queue[devId] = new OpenCLContext(device.getPlatform(), device); + } + OpenCLContext cont = queue[devId]; + OpenCLContextThread t = new OpenCLContextThread(device, cont, r); + t.setPriority(Thread.NORM_PRIORITY - 1); + t.setDaemon(true); + String type = device.getDeviceType().toString(); + t.setName(String.format("%s%d-Queue%d-Worker-%d", type, devId, queueId, idv)); + return t; + } + } + ); + } + + /** + * 创建混合线程池: + * - 每张显卡创建 threadsPerDevice 个绑定队列的 GPU 线程 + * - 如果 GPU 线程总数不足 minThreads,补足普通 CPU 线程 + * + * @param devices OpenCL 设备列表(可以为空) + * @param threadsPerDevice 每张显卡的 GPU 线程数 + * @param minThreads 线程池最小线程数 + * @return 混合线程池 + */ + public static ExecutorService newHybridThreadPool(List devices, int threadsPerDevice, int minThreads) { + if (threadsPerDevice < 0) { + throw new IllegalArgumentException("每个设备的线程数不能为负数"); + } + if (minThreads <= 0) { + throw new IllegalArgumentException("最小线程数必须大于 0"); + } + + // 先计算 GPU 线程数 + int gpuThreads = 0; + if (devices != null && !devices.isEmpty()) { + gpuThreads = devices.size() * threadsPerDevice; + } + + // 补足 CPU 线程 + int cpuThreads = Math.max(0, minThreads - gpuThreads); + int totalThreads = gpuThreads + cpuThreads; + boolean hasGPU = devices != null && !devices.isEmpty() && threadsPerDevice > 0; + + // 🔥 关键:将 gpuThreads 声明为 final + final int finalGpuThreads = gpuThreads; + + return (ThreadPoolExecutor) Executors.newFixedThreadPool( + totalThreads, + new ThreadFactory() { + private final AtomicInteger id = new AtomicInteger(0); + private final OpenCLContext[] contexts = hasGPU ? new OpenCLContext[devices.size()] : null; + private final AtomicInteger cpuThreadCounter = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + int idv = id.getAndIncrement(); + + // ✅ 使用 finalGpuThreads 替代 gpuThreads + if (hasGPU && idv < finalGpuThreads) { + int devId = idv / threadsPerDevice; + int queueId = idv % threadsPerDevice; + OpenCLDevice device = devices.get(devId); + if (contexts[devId] == null) { + contexts[devId] = new OpenCLContext(device.getPlatform(), device); + } + OpenCLContext cont = contexts[devId]; + OpenCLContextThread t = new OpenCLContextThread(device, cont, r); + t.setPriority(Thread.NORM_PRIORITY - 1); + t.setDaemon(true); + String type = device.getDeviceType().toString(); + t.setName(String.format("%s%d-Queue%d-Worker-%d", type, devId, queueId, idv)); + return t; + } + + // CPU 线程 + Thread t = new Thread(r); + t.setPriority(Thread.NORM_PRIORITY - 1); + t.setDaemon(true); + int cpuId = cpuThreadCounter.getAndIncrement(); + t.setName(hasGPU ? String.format("CPU-Worker-%d", cpuId) : String.format("CPU-Worker-%d", idv)); + return t; + } + } + ); + } +} \ No newline at end of file diff --git a/src/org/kne/opencl64/concurrent/ThreadLocalOpenCLMemory.java b/src/org/kne/opencl64/concurrent/ThreadLocalOpenCLMemory.java new file mode 100644 index 0000000..508b704 --- /dev/null +++ b/src/org/kne/opencl64/concurrent/ThreadLocalOpenCLMemory.java @@ -0,0 +1,21 @@ +package org.kne.opencl64.concurrent; + +import org.kne.opencl64.OpenCLContext; +import org.kne.opencl64.OpenCLMemory; + +public class ThreadLocalOpenCLMemory extends ThreadLocal { + + public OpenCLMemory get(OpenCLContext context,long size) { + OpenCLMemory ocm=super.get(); + if(ocm==null||ocm.byteSize()