summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2014-11-13 13:39:20 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-11-13 14:19:35 +0800
commit6560fe7f774dff4f68dc9446d9252bd11a718e26 (patch)
tree077504097adfdbe833375f1c7cd905876b94c46c /src
parent198344741a988849c0c77bb8de97062fcc54f1b9 (diff)
runtime: fix bug in cl_enqueue_read_buffer.
If the buffer is a userptr buffer, we should copy it directly. Otherwise, it fails in libdrm. As drm_intel_gem_bo_subdata() refuses to read a userptr buffer object. Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Reviewed-by: "Guo, Yejun" <yejun.guo@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/cl_enqueue.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/cl_enqueue.c b/src/cl_enqueue.c
index fcffd051..5798e20f 100644
--- a/src/cl_enqueue.c
+++ b/src/cl_enqueue.c
@@ -31,13 +31,18 @@
cl_int cl_enqueue_read_buffer(enqueue_data* data)
{
+ cl_int err = CL_SUCCESS;
cl_mem mem = data->mem_obj;
assert(mem->type == CL_MEM_BUFFER_TYPE ||
mem->type == CL_MEM_SUBBUFFER_TYPE);
struct _cl_mem_buffer* buffer = (struct _cl_mem_buffer*)mem;
-
- return cl_buffer_get_subdata(mem->bo, data->offset + buffer->sub_offset,
- data->size, data->ptr);
+ if (!mem->is_userptr) {
+ if (cl_buffer_get_subdata(mem->bo, data->offset + buffer->sub_offset,
+ data->size, data->ptr) != 0)
+ err = CL_MAP_FAILURE;
+ } else
+ memcpy(data->ptr, (char*)mem->host_ptr + data->offset + buffer->sub_offset, data->size);
+ return err;
}
cl_int cl_enqueue_read_buffer_rect(enqueue_data* data)