[Beignet] [PATCH] runtime: fix bug in cl_enqueue_read_buffer.
Guo, Yejun
yejun.guo at intel.com
Wed Nov 12 22:52:39 PST 2014
LGTM, thanks.
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zhigang Gong
Sent: Thursday, November 13, 2014 1:43 PM
To: beignet at lists.freedesktop.org
Cc: Gong, Zhigang
Subject: [Beignet] [PATCH] 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 at intel.com>
---
src/cl_enqueue.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/cl_enqueue.c b/src/cl_enqueue.c
index fcffd05..5798e20 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)
--
1.8.3.2
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list