[Beignet] [PATCH] support clGetImageInfo
Xing, Homer
homer.xing at intel.com
Wed Jul 10 01:18:17 PDT 2013
OK. Will add a test case in get_cl_info.cpp
-----Original Message-----
From: He Junyan [mailto:junyan.he at inbox.com]
Sent: Wednesday, July 10, 2013 4:01 PM
To: Xing, Homer
Cc: beignet at lists.freedesktop.org
Subject: Re: [Beignet] [PATCH] support clGetImageInfo
I think it is better to add a case in get_cl_info.cpp as all other getXXXinfo-like APIs.
On 07/10/2013 02:20 PM, Homer Hsing wrote:
> clGetImageInfo() is an OpenCL API. It returns information of an image.
>
> This patch makes Piglit test case "clGetImageInfo" pass.
>
> Signed-off-by: Homer Hsing <homer.xing at intel.com>
> ---
> src/cl_api.c | 7 +++++--
> src/cl_mem.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> src/cl_mem.h | 3 +++
> 3 files changed, 59 insertions(+), 2 deletions(-)
>
> diff --git a/src/cl_api.c b/src/cl_api.c index dc52f0a..277f7a9 100644
> --- a/src/cl_api.c
> +++ b/src/cl_api.c
> @@ -573,8 +573,11 @@ clGetImageInfo(cl_mem image,
> void * param_value,
> size_t * param_value_size_ret)
> {
> - NOT_IMPLEMENTED;
> - return 0;
> + return cl_get_image_info(image,
> + param_name,
> + param_value_size,
> + param_value,
> + param_value_size_ret);
> }
>
> cl_int
> diff --git a/src/cl_mem.c b/src/cl_mem.c index 5465aa9..064ecb3 100644
> --- a/src/cl_mem.c
> +++ b/src/cl_mem.c
> @@ -90,6 +90,57 @@ cl_get_mem_object_info(cl_mem mem,
> return CL_SUCCESS;
> }
>
> +LOCAL cl_int
> +cl_get_image_info(cl_mem mem,
> + cl_image_info param_name,
> + size_t param_value_size,
> + void *param_value,
> + size_t *param_value_size_ret) {
> + if(!mem || !mem->is_image)
> + return CL_INVALID_MEM_OBJECT;
> +
> + switch(param_name)
> + {
> + FIELD_SIZE(IMAGE_FORMAT, cl_image_format);
> + FIELD_SIZE(IMAGE_ELEMENT_SIZE, size_t);
> + FIELD_SIZE(IMAGE_ROW_PITCH, size_t);
> + FIELD_SIZE(IMAGE_SLICE_PITCH, size_t);
> + FIELD_SIZE(IMAGE_WIDTH, size_t);
> + FIELD_SIZE(IMAGE_HEIGHT, size_t);
> + FIELD_SIZE(IMAGE_DEPTH, size_t);
> + default:
> + return CL_INVALID_VALUE;
> + }
> +
> + switch(param_name)
> + {
> + case CL_IMAGE_FORMAT:
> + *(cl_image_format *)param_value = mem->fmt;
> + break;
> + case CL_IMAGE_ELEMENT_SIZE:
> + *(size_t *)param_value = mem->bpp;
> + break;
> + case CL_IMAGE_ROW_PITCH:
> + *(size_t *)param_value = mem->row_pitch;
> + break;
> + case CL_IMAGE_SLICE_PITCH:
> + *(size_t *)param_value = mem->slice_pitch;
> + break;
> + case CL_IMAGE_WIDTH:
> + *(size_t *)param_value = mem->w;
> + break;
> + case CL_IMAGE_HEIGHT:
> + *(size_t *)param_value = mem->h;
> + break;
> + case CL_IMAGE_DEPTH:
> + *(size_t *)param_value = mem->depth;
> + break;
> + }
> +
> + return CL_SUCCESS;
> +}
> +
> #undef FIELD_SIZE
>
> static cl_mem
> diff --git a/src/cl_mem.h b/src/cl_mem.h index c204992..c63bf6c 100644
> --- a/src/cl_mem.h
> +++ b/src/cl_mem.h
> @@ -73,6 +73,9 @@ struct _cl_mem {
> /* Query information about a memory object */
> extern cl_int cl_get_mem_object_info(cl_mem, cl_mem_info, size_t,
> void *, size_t *);
>
> +/* Query information about an image */ extern cl_int
> +cl_get_image_info(cl_mem, cl_image_info, size_t, void *, size_t *);
> +
> /* Create a new memory object and initialize it with possible user data */
> extern cl_mem cl_mem_new(cl_context, cl_mem_flags, size_t, void*,
> cl_int*);
>
More information about the Beignet
mailing list