[Piglit] [PATCH RESEND] cl: Fix image support when built on CL<1.2
Serge Martin
edb+piglit at sigluy.net
Sun Apr 24 08:08:40 UTC 2016
On Monday 04 April 2016 08:55:48 Jan Vesely wrote:
> On Mon, 2016-03-28 at 21:17 -0400, Jan Vesely wrote:
> > Provide our own image_desc structure since it's too tangled to
> > remove.
> > Tests that require OCL 1.2 result in WARN:
> > Piglit was compiled with lower OpenCL version (1.1) than version_min:
> > 12.
> > OCL 1.1 image tests pass on Intel CPU OCL when compiled in 1.1
> > environment.
>
> gentle ping.
Reviewed-by: Serge Martin <edb+piglit at sigluy.net>
>
> > Signed-off-by: Jan Vesely <jano.vesely at gmail.com>
> > ---
> >
> > Looks like the first one did not make it to the ML.
> >
> > tests/cl/program/program-tester.c | 2 +-
> > tests/util/piglit-util-cl.c | 34 ++++++++++++++++++++---------
> > -----
> > tests/util/piglit-util-cl.h | 20 +++++++++++++++++++-
> > 3 files changed, 40 insertions(+), 16 deletions(-)
> >
> > diff --git a/tests/cl/program/program-tester.c
> > b/tests/cl/program/program-tester.c
> > index 3e0ed43..0a3b011 100644
> > --- a/tests/cl/program/program-tester.c
> > +++ b/tests/cl/program/program-tester.c
> > @@ -345,7 +345,7 @@ struct test_arg {
> > uint64_t ulp;
> >
> > /* image data */
> > - cl_image_desc image_desc;
> > + piglit_image_desc image_desc;
> > cl_image_format image_format;
> >
> > /* sampler data */
> > diff --git a/tests/util/piglit-util-cl.c b/tests/util/piglit-util-
> > cl.c
> > index 9bf45a2..efa289c 100644
> > --- a/tests/util/piglit-util-cl.c
> > +++ b/tests/util/piglit-util-cl.c
> > @@ -1006,14 +1006,18 @@ piglit_cl_read_whole_buffer(cl_command_queue
> > command_queue, cl_mem buffer,
> >
> > cl_mem
> > piglit_cl_create_image(piglit_cl_context context, cl_mem_flags
> > flags,
> > - const cl_image_format *format, const
> > cl_image_desc *desc)
> > + const cl_image_format *format,
> > + const piglit_image_desc *desc)
> > {
> > cl_int errNo;
> > cl_mem image = NULL;
> >
> > +#ifdef CL_VERSION_1_2
> > if (piglit_cl_get_platform_version(context->platform_id) >=
> > 12) {
> > image = clCreateImage(context->cl_ctx, flags,
> > format, desc, NULL, &errNo);
> > - } else if (desc->image_type == CL_MEM_OBJECT_IMAGE2D) {
> > + } else
> > +#endif
> > + if (desc->image_type == CL_MEM_OBJECT_IMAGE2D) {
> > image = clCreateImage2D(context->cl_ctx, flags,
> > format,
> > desc->image_width, desc-
> >
> > >image_height, 0,
> >
> > NULL, &errNo);
> > @@ -1068,36 +1072,38 @@ piglit_get_image_region(cl_mem image, size_t
> > *region)
> > free(p);
> >
> > switch (*type) {
> > +#ifdef CL_VERSION_1_2
> > + case CL_MEM_OBJECT_IMAGE1D_ARRAY:
> > + p = piglit_cl_get_image_info(image,
> > CL_IMAGE_ARRAY_SIZE);
> > + region[1] = *p;
> > + free(p);
> > + region[2] = 1;
> > + break;
> > case CL_MEM_OBJECT_IMAGE1D:
> > case CL_MEM_OBJECT_IMAGE1D_BUFFER:
> > region[1] = 1;
> > region[2] = 1;
> > break;
> > - case CL_MEM_OBJECT_IMAGE2D:
> > - p = piglit_cl_get_image_info(image,
> > CL_IMAGE_HEIGHT);
> > - region[1] = *p;
> > - free(p);
> > - region[2] = 1;
> > - break;
> > - case CL_MEM_OBJECT_IMAGE3D:
> > + case CL_MEM_OBJECT_IMAGE2D_ARRAY:
> > p = piglit_cl_get_image_info(image,
> > CL_IMAGE_HEIGHT);
> > region[1] = *p;
> > free(p);
> > - p = piglit_cl_get_image_info(image,
> > CL_IMAGE_DEPTH);
> > + p = piglit_cl_get_image_info(image,
> > CL_IMAGE_ARRAY_SIZE);
> > region[2] = *p;
> > free(p);
> > break;
> > - case CL_MEM_OBJECT_IMAGE1D_ARRAY:
> > - p = piglit_cl_get_image_info(image,
> > CL_IMAGE_ARRAY_SIZE);
> > +#endif
> > + case CL_MEM_OBJECT_IMAGE2D:
> > + p = piglit_cl_get_image_info(image,
> > CL_IMAGE_HEIGHT);
> > region[1] = *p;
> > free(p);
> > region[2] = 1;
> > break;
> > - case CL_MEM_OBJECT_IMAGE2D_ARRAY:
> > + case CL_MEM_OBJECT_IMAGE3D:
> > p = piglit_cl_get_image_info(image,
> > CL_IMAGE_HEIGHT);
> > region[1] = *p;
> > free(p);
> > - p = piglit_cl_get_image_info(image,
> > CL_IMAGE_ARRAY_SIZE);
> > + p = piglit_cl_get_image_info(image,
> > CL_IMAGE_DEPTH);
> > region[2] = *p;
> > free(p);
> > break;
> > diff --git a/tests/util/piglit-util-cl.h b/tests/util/piglit-util-
> > cl.h
> > index 8526a9a..0330740 100644
> > --- a/tests/util/piglit-util-cl.h
> > +++ b/tests/util/piglit-util-cl.h
> > @@ -527,6 +527,24 @@ bool
> > piglit_cl_read_whole_buffer(cl_command_queue command_queue,
> > cl_mem buffer,
> > void *ptr);
> > +#ifdef CL_VERSION_1_2
> > +typedef cl_image_desc piglit_image_desc;
> > +#else
> > +/** Taken from OpenCL 1.2 specs 5.3.1.2 */
> > +typedef struct {
> > + cl_mem_object_type image_type;
> > + size_t image_width;
> > + size_t image_height;
> > + size_t image_depth;
> > + size_t image_array_size;
> > + size_t image_row_pitch;
> > + size_t image_slice_pitch;
> > + cl_uint num_mip_levels;
> > + cl_uint num_samples;
> > + cl_mem buffer;
> > +} piglit_image_desc;
> > +#endif
> > +
> >
> > /**
> > * \brief Create an image.
> > @@ -541,7 +559,7 @@ cl_mem
> > piglit_cl_create_image(piglit_cl_context context,
> > cl_mem_flags flags,
> > const cl_image_format *format,
> > - const cl_image_desc *desc);
> > + const piglit_image_desc *desc);
> >
> > /**
> > * \brief Blocking write to an image.
More information about the Piglit
mailing list