use of de.mirkosertic.bytecoder.api.opencl.FloatSerializable in project Bytecoder by mirkosertic.
the class OpenCLContext method toDataRef.
private static DataRef toDataRef(Object[] aArray, Class aDataType) {
if (FloatSerializable.class.isAssignableFrom(aDataType)) {
OpenCLType theType = (OpenCLType) aDataType.getAnnotation(OpenCLType.class);
int theSize = aArray.length * theType.elementCount();
FloatBuffer theBuffer = FloatBuffer.allocate(theSize);
for (Object anAArray : aArray) {
FloatSerializable theVec = (FloatSerializable) anAArray;
theVec.writeTo(theBuffer);
}
return new DataRef(Pointer.to(theBuffer), Sizeof.cl_float * theSize) {
@Override
public void updateFromBuffer() {
theBuffer.rewind();
for (Object anAArray : aArray) {
FloatSerializable theVec = (FloatSerializable) anAArray;
theVec.readFrom(theBuffer);
}
}
};
}
throw new IllegalArgumentException("Not supported datatype : " + aDataType);
}
Aggregations