[Mesa-dev] [PATCH 1/4] clover: Implement 'CL_MEM_OBJECT_IMAGE2D_ARRAY'

Francisco Jerez currojerez at riseup.net
Mon Dec 12 01:50:57 UTC 2016


Edward O'Callaghan <funfunctor at folklore1984.net> writes:

> On 11/25/2016 03:38 PM, Francisco Jerez wrote:
>> Edward O'Callaghan <funfunctor at folklore1984.net> writes:
>> 
>>> Signed-off-by: Edward O'Callaghan <funfunctor at folklore1984.net>
>>> ---
>>>  src/gallium/state_trackers/clover/api/memory.cpp  | 17 ++++++++++++++++-
>>>  src/gallium/state_trackers/clover/core/memory.cpp | 14 ++++++++++++++
>>>  src/gallium/state_trackers/clover/core/memory.hpp | 11 +++++++++++
>>>  3 files changed, 41 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp
>>> index 9b3cd8b..58f56d1 100644
>>> --- a/src/gallium/state_trackers/clover/api/memory.cpp
>>> +++ b/src/gallium/state_trackers/clover/api/memory.cpp
>>> @@ -181,6 +181,22 @@ clCreateImage(cl_context d_ctx, cl_mem_flags d_flags,
>>>                           desc->image_width, desc->image_height,
>>>                           desc->image_row_pitch, host_ptr);
>>>  
>>> +   case CL_MEM_OBJECT_IMAGE2D_ARRAY:
>>> +      if (!desc->image_width || !desc->image_height)
>>> +         throw error(CL_INVALID_IMAGE_SIZE);
>>> +
>>> +      if (all_of([=](const device &dev) {
>>> +               const size_t max = 1 << dev.max_image_levels_2d();
>>> +               return (desc->image_width > max ||
>>> +                       desc->image_height > max);
>>> +            }, ctx.devices()))
>>> +         throw error(CL_INVALID_IMAGE_SIZE);
>>> +
>>> +      return new image2d_array(ctx, flags, format,
>>> +                               desc->image_width, desc->image_height,
>>> +                               desc->image_array_size, desc->image_slice_pitch,
>>> +                               host_ptr);
>>> +
>>>     case CL_MEM_OBJECT_IMAGE3D:
>>>        if (!desc->image_width || !desc->image_height || !desc->image_depth)
>>>           throw error(CL_INVALID_IMAGE_SIZE);
>>> @@ -201,7 +217,6 @@ clCreateImage(cl_context d_ctx, cl_mem_flags d_flags,
>>>     case CL_MEM_OBJECT_IMAGE1D:
>>>     case CL_MEM_OBJECT_IMAGE1D_ARRAY:
>>>     case CL_MEM_OBJECT_IMAGE1D_BUFFER:
>>> -   case CL_MEM_OBJECT_IMAGE2D_ARRAY:
>>>        // XXX - Not implemented.
>>>        throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED);
>>>  
>>> diff --git a/src/gallium/state_trackers/clover/core/memory.cpp b/src/gallium/state_trackers/clover/core/memory.cpp
>>> index b852e68..de1862b 100644
>>> --- a/src/gallium/state_trackers/clover/core/memory.cpp
>>> +++ b/src/gallium/state_trackers/clover/core/memory.cpp
>>> @@ -198,6 +198,20 @@ image2d::type() const {
>>>     return CL_MEM_OBJECT_IMAGE2D;
>>>  }
>>>  
>>> +image2d_array::image2d_array(clover::context &ctx, cl_mem_flags flags,
>>> +                             const cl_image_format *format,
>>> +                             size_t width, size_t height,
>>> +                             size_t array_size, size_t slice_pitch,
>>> +                             void *host_ptr) :
>>> +   image(ctx, flags, format, width, height, 1,
>>> +         0, slice_pitch, slice_pitch * array_size, host_ptr) {
>>> +}
>> 
>> Seems like you aren't passing the row pitch as argument, and the array
>> size is getting lost so you won't be able to recover it in order to
>> implement memory transfer functions and CL image queries.
> So I should extend the image base class with a private _array_size state
> and a const getter method also, would that be reasonable?
>

Yeah, that sounds reasonable to me.

>> 
>>> +
>>> +cl_mem_object_type
>>> +image2d_array::type() const {
>>> +   return CL_MEM_OBJECT_IMAGE2D_ARRAY;
>>> +}
>>> +
>>>  image3d::image3d(clover::context &ctx, cl_mem_flags flags,
>>>                   const cl_image_format *format,
>>>                   size_t width, size_t height, size_t depth,
>>> diff --git a/src/gallium/state_trackers/clover/core/memory.hpp b/src/gallium/state_trackers/clover/core/memory.hpp
>>> index bd6da6b..1a3e8c9 100644
>>> --- a/src/gallium/state_trackers/clover/core/memory.hpp
>>> +++ b/src/gallium/state_trackers/clover/core/memory.hpp
>>> @@ -144,6 +144,17 @@ namespace clover {
>>>        virtual cl_mem_object_type type() const;
>>>     };
>>>  
>>> +   class image2d_array : public image {
>>> +   public:
>>> +      image2d_array(clover::context &ctx, cl_mem_flags flags,
>>> +                    const cl_image_format *format,
>>> +                    size_t width, size_t height,
>>> +                    size_t array_size, size_t slice_pitch,
>>> +                    void *host_ptr);
>>> +
>>> +      virtual cl_mem_object_type type() const;
>>> +   };
>>> +
>>>     class image3d : public image {
>>>     public:
>>>        image3d(clover::context &ctx, cl_mem_flags flags,
>>> -- 
>>> 2.7.4
>>>
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev at lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161211/a85df9f8/attachment.sig>


More information about the mesa-dev mailing list