[Beignet] [PATCH] Fix clEnqueueMapImage error.

Lu, Guanqun guanqun.lu at intel.com
Mon Sep 23 00:06:02 PDT 2013


I would suggest you should add { } in the first if clause. because it has nested if statement, that should be much clean.

> -----Original Message-----
> From: beignet-bounces+guanqun.lu=intel.com at lists.freedesktop.org
> [mailto:beignet-bounces+guanqun.lu=intel.com at lists.freedesktop.org] On
> Behalf Of Yang Rong
> Sent: Monday, September 23, 2013 1:16 PM
> To: beignet at lists.freedesktop.org
> Cc: Yang, Rong R
> Subject: [Beignet] [PATCH] Fix clEnqueueMapImage error.
> 
> Correct map size calc and remove ptr + offset because has done in
> _cl_map_mem.
> 
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
>  src/cl_api.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cl_api.c b/src/cl_api.c
> index c81f730..b60160b 100644
> --- a/src/cl_api.c
> +++ b/src/cl_api.c
> @@ -2155,13 +2155,22 @@ clEnqueueMapImage(cl_command_queue
> command_queue,
>    }
> 
>    size_t offset = image->bpp*origin[0] + image->row_pitch*origin[1] +
> image->slice_pitch*origin[2];
> -  size_t size = image->depth == 1 ? image->row_pitch*image->h :
> image->slice_pitch*image->depth;
> +  size_t size;
> +  if(region[2] == 1)
> +    if(region[1] == 1)
> +      size = image->bpp * region[0];
> +    else
> +      size = image->row_pitch * (region[1] - 1) + (image->bpp * (origin[0] +
> region[0]));
> +  else {
> +    size = image->slice_pitch * (region[2] - 1);
> +    size += image->row_pitch * (origin[1] + region[1]);
> +    size += image->bpp * (origin[0] + region[0]);
> +  }
> 
>    err = _cl_map_mem(mem, &ptr, &mem_ptr, offset, size);
>    if (err != CL_SUCCESS)
>      goto error;
> 
> -  ptr = (char*)ptr + offset;
>    TRY(cl_event_check_waitlist, num_events_in_wait_list, event_wait_list,
> event, mem->ctx);
> 
>    data = &no_wait_data;
> --
> 1.8.1.2
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list