[Mesa-dev] [PATCH] clover: Add a stub implementation of clCreateImage() v3

Francisco Jerez currojerez at riseup.net
Thu May 1 15:00:45 PDT 2014


Tom Stellard <thomas.stellard at amd.com> writes:

> Now that we are uisng the OpenCL 1.2 headers, applications expect all
> the OpenCL 1.2 functions to be implemented.
>
> This fixes linking errors with the piglit CL tests.
>
> v2:
>   - Use c++ features
>   - Fix error code handling
>
> v3:
>   - Move <iostream> into api/util.hpp
>   - Fix indentation

Thanks,

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> ---
>  src/gallium/state_trackers/clover/api/dispatch.cpp |  2 +-
>  src/gallium/state_trackers/clover/api/dispatch.hpp |  8 +++++++-
>  src/gallium/state_trackers/clover/api/memory.cpp   | 12 ++++++++++++
>  src/gallium/state_trackers/clover/api/util.hpp     |  1 +
>  4 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp b/src/gallium/state_trackers/clover/api/dispatch.cpp
> index 2ee6208..488e654 100644
> --- a/src/gallium/state_trackers/clover/api/dispatch.cpp
> +++ b/src/gallium/state_trackers/clover/api/dispatch.cpp
> @@ -120,7 +120,7 @@ namespace clover {
>        clCreateSubDevices,
>        clRetainDevice,
>        clReleaseDevice,
> -      NULL, // clCreateImage
> +      clCreateImage,
>        NULL, // clCreateProgramWithBuiltInKernels
>        NULL, // clCompileProgram
>        NULL, // clLinkProgram
> diff --git a/src/gallium/state_trackers/clover/api/dispatch.hpp b/src/gallium/state_trackers/clover/api/dispatch.hpp
> index 833fb0e..ffae1ae 100644
> --- a/src/gallium/state_trackers/clover/api/dispatch.hpp
> +++ b/src/gallium/state_trackers/clover/api/dispatch.hpp
> @@ -653,7 +653,13 @@ struct _cl_icd_dispatch {
>     CL_API_ENTRY cl_int (CL_API_CALL *clReleaseDevice)(
>        cl_device_id device);
>  
> -   void *clCreateImage;
> +   CL_API_ENTRY cl_mem (CL_API_CALL *clCreateImage)(
> +      cl_context context,
> +      cl_mem_flags flags,
> +      const cl_image_format *image_format,
> +      const cl_image_desc *image_desc,
> +      void *host_ptr,
> +      cl_int *errcode_ret);
>  
>     CL_API_ENTRY cl_program (CL_API_CALL *clCreateProgramWithBuiltInKernels)(
>        cl_context context,
> diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp
> index 7ed2191..d26b1c6 100644
> --- a/src/gallium/state_trackers/clover/api/memory.cpp
> +++ b/src/gallium/state_trackers/clover/api/memory.cpp
> @@ -334,3 +334,15 @@ clSetMemObjectDestructorCallback(cl_mem d_mem,
>  } catch (error &e) {
>     return e.get();
>  }
> +
> +CLOVER_API cl_mem
> +clCreateImage(cl_context d_ctx, cl_mem_flags flags,
> +              const cl_image_format *format,
> +              const cl_image_desc *image_desc,
> +              void *host_ptr, cl_int *r_errcode) {
> +   // This function was added in OpenCL 1.2
> +   std::cerr << "CL user error: clCreateImage() not supported by OpenCL 1.1." <<
> +                std::endl;
> +   ret_error(r_errcode, CL_INVALID_OPERATION);
> +   return NULL;
> +}
> diff --git a/src/gallium/state_trackers/clover/api/util.hpp b/src/gallium/state_trackers/clover/api/util.hpp
> index c2b216e..918df61 100644
> --- a/src/gallium/state_trackers/clover/api/util.hpp
> +++ b/src/gallium/state_trackers/clover/api/util.hpp
> @@ -24,6 +24,7 @@
>  #define CLOVER_API_UTIL_HPP
>  
>  #include <cassert>
> +#include <iostream>
>  
>  #include "core/error.hpp"
>  #include "core/property.hpp"
> -- 
> 1.8.1.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140502/1f9e7d68/attachment.sig>


More information about the mesa-dev mailing list