func (ctx *Context) CreateBufferUnsafe(flags MemFlag, size int, dataPtr unsafe.Pointer) (*MemObject, error) { var err C.cl_int clBuffer := C.clCreateBuffer(ctx.clContext, C.cl_mem_flags(flags), C.size_t(size), dataPtr, &err) if err != C.CL_SUCCESS { return nil, toError(err) } if clBuffer == nil { return nil, ErrUnknown } return newMemObject(clBuffer, size), nil }
func (c *Context) NewBuffer(flags MemFlags, size uint32) (*Buffer, error) { var c_buffer C.cl_mem var err C.cl_int if c_buffer = C.clCreateBuffer(c.id, C.cl_mem_flags(flags), C.size_t(size), nil, &err); err != C.CL_SUCCESS { return nil, Cl_error(err) } buffer := &Buffer{id: c_buffer} runtime.SetFinalizer(buffer, (*Buffer).release) return buffer, nil }
func CLCreateBuffer(context CL_context, flags CL_mem_flags, size CL_size_t, host_ptr unsafe.Pointer, errcode_ret *CL_int) CL_mem { var c_errcode_ret C.cl_int var c_memobj C.cl_mem c_memobj = C.clCreateBuffer(context.cl_context, C.cl_mem_flags(flags), C.size_t(size), host_ptr, &c_errcode_ret) if errcode_ret != nil { *errcode_ret = CL_int(c_errcode_ret) } return CL_mem{c_memobj} }
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateBuffer.html func CreateBuffer(context Context, flags, paramValueSize MemFlags, hostPtr unsafe.Pointer, errcode *ErrorCode) Mem { return Mem(C.clCreateBuffer(context.clContext, C.cl_mem_flags(flags), C.size_t(paramValueSize), hostPtr, (*C.cl_int)(unsafe.Pointer(errcode)))) }