diff options
author | Serge Martin <[email protected]> | 2015-09-19 23:16:10 +0200 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2015-09-28 18:10:39 +0300 |
commit | 2518645f63e2f66d3638180f44a007541928319c (patch) | |
tree | 852204c427b5a52b442241eff18962a8150eb209 /src/gallium/state_trackers/clover/api | |
parent | f2c52e392bdaa9ce9b9075996eb5efafde142030 (diff) |
clover: Implement clCreateImage?D w/ clCreateImage.
Remplace clCreateImage2D and clCreateImage3D implementation with call
to clCreateImage.
Reviewed-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover/api')
-rw-r--r-- | src/gallium/state_trackers/clover/api/memory.cpp | 60 |
1 files changed, 8 insertions, 52 deletions
diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp index de48908d878..9b3cd8b1f5c 100644 --- a/src/gallium/state_trackers/clover/api/memory.cpp +++ b/src/gallium/state_trackers/clover/api/memory.cpp @@ -218,33 +218,11 @@ 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 = validate_flags(NULL, d_flags); - auto &ctx = obj(d_ctx); - - 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); + void *host_ptr, cl_int *r_errcode) { + const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE2D, width, height, 0, 0, + row_pitch, 0, 0, 0, NULL }; - 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; + return clCreateImage(d_ctx, d_flags, format, &desc, host_ptr, r_errcode); } CLOVER_API cl_mem @@ -252,33 +230,11 @@ 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 = validate_flags(NULL, d_flags); - auto &ctx = obj(d_ctx); - - 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); + void *host_ptr, cl_int *r_errcode) { + const cl_image_desc desc = { CL_MEM_OBJECT_IMAGE3D, width, height, depth, 0, + row_pitch, slice_pitch, 0, 0, NULL }; - 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; + return clCreateImage(d_ctx, d_flags, format, &desc, host_ptr, r_errcode); } CLOVER_API cl_int |