Example #1
0
func (b *MemObject) CreateSubBufferRegion(flags MemFlag, origin int, size int) (*MemObject, error) {
	var err C.cl_int
	ci := C.cl_buffer_region{
		origin: C.size_t(origin),
		size:   C.size_t(size),
	}
	clBuffer := C.clCreateSubBuffer(b.clMem, C.cl_mem_flags(flags),
		C.CL_BUFFER_CREATE_TYPE_REGION, unsafe.Pointer(&ci), &err)
	if err != C.CL_SUCCESS {
		return nil, toError(err)
	}
	if clBuffer == nil {
		return nil, ErrUnknown
	}
	return newMemObject(clBuffer, size), nil
}
Example #2
0
func CLCreateSubBuffer(buffer CL_mem,
	flags CL_mem_flags,
	buffer_create_type CL_buffer_create_type,
	buffer_create_info unsafe.Pointer,
	errcode_ret *CL_int) CL_mem {

	var c_errcode_ret C.cl_int
	var c_memobj C.cl_mem

	c_memobj = C.clCreateSubBuffer(buffer.cl_mem,
		C.cl_mem_flags(flags),
		C.cl_buffer_create_type(buffer_create_type),
		buffer_create_info,
		&c_errcode_ret)

	if errcode_ret != nil {
		*errcode_ret = CL_int(c_errcode_ret)
	}

	return CL_mem{c_memobj}
}