I don't plan to use OpenCL yet, an OpenGL compute shader would be enough to perform some computations on the GPU.
Yes, such management could be done in com.jogamp.common.nio.Buffers.newDirectByteBuffer(final int numElements) {
return nativeOrder(directByteBufferAllocator.apply(Integer.valueOf(numElements)));
}
private static Function<Integer, ByteBuffer> directByteBufferAllocator = ByteBuffer::allocateDirect;
public static void setDirectByteBufferAllocator(final Function<Integer, ByteBuffer> directByteBufferAllocator) {
Buffers.directByteBufferAllocator = Objects.requireNonNull(directByteBufferAllocator);
}
Another solution would consist of duplicating many calls to accept java.lang.foreign.MemorySegment instead of java.nio.Buffer but it's too early to do that.