Serge Martin <[email protected]> writes: > remplace clCreateImage2D and clCreateImage3D implementation with call to > clCreateImage > --- > src/gallium/state_trackers/clover/api/memory.cpp | 92 > +++++++++--------------- > 1 file changed, 32 insertions(+), 60 deletions(-) > > diff --git a/src/gallium/state_trackers/clover/api/memory.cpp > b/src/gallium/state_trackers/clover/api/memory.cpp > index 6e95931..50721d1 100644 > --- a/src/gallium/state_trackers/clover/api/memory.cpp > +++ b/src/gallium/state_trackers/clover/api/memory.cpp > @@ -227,36 +227,22 @@ CLOVER_API cl_mem > clCreateImage2D(cl_context d_ctx, cl_mem_flags d_flags, > const cl_image_format *format, > size_t width, size_t height, size_t row_pitch, > - void *host_ptr, cl_int *r_errcode) try { > - const cl_mem_flags flags = d_flags | > - (d_flags & dev_access_flags ? 0 : CL_MEM_READ_WRITE); > - auto &ctx = obj(d_ctx); > - > - validate_flags(d_flags, all_mem_flags); > - > - if (!any_of(std::mem_fn(&device::image_support), ctx.devices())) > - throw error(CL_INVALID_OPERATION); > - > - if (!format) > - throw error(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR); > - > - if (width < 1 || height < 1) > - throw error(CL_INVALID_IMAGE_SIZE); > - > - if (bool(host_ptr) != bool(flags & (CL_MEM_USE_HOST_PTR | > - CL_MEM_COPY_HOST_PTR))) > - throw error(CL_INVALID_HOST_PTR); > - > - if (!supported_formats(ctx, CL_MEM_OBJECT_IMAGE2D).count(*format)) > - throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED); > - > - ret_error(r_errcode, CL_SUCCESS); > - return new image2d(ctx, flags, format, width, height, > - row_pitch, host_ptr); > - > -} catch (error &e) { > - ret_error(r_errcode, e); > - return NULL; > + void *host_ptr, cl_int *r_errcode) { > + > + const cl_image_desc desc = { > + .image_type = CL_MEM_OBJECT_IMAGE2D, > + .image_width = width, > + .image_height = height, > + .image_depth = 0, > + .image_array_size = 0, > + .image_row_pitch = row_pitch, > + .image_slice_pitch = 0, > + .num_mip_levels = 0, > + .num_samples = 0, > + .buffer = NULL > + }; > +
Designated initializers are a GNU extension in C++, please use a
standard C++ initializer instead:
| const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE2D, width, height, 0, 0,
| row_pitch, 0, 0, 0, NULL };
> + return clCreateImage(d_ctx, d_flags, format, &desc, host_ptr, r_errcode);
> }
>
> CLOVER_API cl_mem
> @@ -264,36 +250,22 @@ clCreateImage3D(cl_context d_ctx, cl_mem_flags d_flags,
> const cl_image_format *format,
> size_t width, size_t height, size_t depth,
> size_t row_pitch, size_t slice_pitch,
> - void *host_ptr, cl_int *r_errcode) try {
> - const cl_mem_flags flags = d_flags |
> - (d_flags & dev_access_flags ? 0 : CL_MEM_READ_WRITE);
> - auto &ctx = obj(d_ctx);
> -
> - validate_flags(d_flags, all_mem_flags);
> -
> - if (!any_of(std::mem_fn(&device::image_support), ctx.devices()))
> - throw error(CL_INVALID_OPERATION);
> -
> - if (!format)
> - throw error(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
> -
> - if (width < 1 || height < 1 || depth < 2)
> - throw error(CL_INVALID_IMAGE_SIZE);
> -
> - if (bool(host_ptr) != bool(flags & (CL_MEM_USE_HOST_PTR |
> - CL_MEM_COPY_HOST_PTR)))
> - throw error(CL_INVALID_HOST_PTR);
> -
> - if (!supported_formats(ctx, CL_MEM_OBJECT_IMAGE3D).count(*format))
> - throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED);
> -
> - ret_error(r_errcode, CL_SUCCESS);
> - return new image3d(ctx, flags, format, width, height, depth,
> - row_pitch, slice_pitch, host_ptr);
> -
> -} catch (error &e) {
> - ret_error(r_errcode, e);
> - return NULL;
> + void *host_ptr, cl_int *r_errcode) {
> +
> + const cl_image_desc desc = {
> + .image_type = CL_MEM_OBJECT_IMAGE3D,
> + .image_width = width,
> + .image_height = height,
> + .image_depth = depth,
> + .image_array_size = 0,
> + .image_row_pitch = row_pitch,
> + .image_slice_pitch = slice_pitch,
> + .num_mip_levels = 0,
> + .num_samples = 0,
> + .buffer = NULL
> + };
Same here.
> +
> + return clCreateImage(d_ctx, d_flags, format, &desc, host_ptr, r_errcode);
> }
>
> CLOVER_API cl_int
> --
> 2.5.2
>
> _______________________________________________
> mesa-dev mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
signature.asc
Description: PGP signature
_______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
