clover: Implement CL_MEM_OBJECT_IMAGE1D_BUFFER
authorEdward O'Callaghan <funfunctor@folklore1984.net>
Fri, 18 Nov 2016 05:51:14 +0000 (16:51 +1100)
committerDave Airlie <airlied@redhat.com>
Mon, 18 Oct 2021 02:23:41 +0000 (12:23 +1000)
v2: Consider surface height as valid when unused by using 1.
     Fixup width boundary checking.
v3 (Karol): Pull in changes from later commits
v4:(airlied): use max_buffer_size as the limit (Fixes CTS test)

Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13401>

src/gallium/frontends/clover/api/memory.cpp
src/gallium/frontends/clover/core/memory.cpp
src/gallium/frontends/clover/core/memory.hpp

index 668d86b..014baba 100644 (file)
@@ -228,6 +228,20 @@ clCreateImageWithProperties(cl_context d_ctx,
                          desc->image_width,
                          row_pitch, host_ptr);
 
+   case CL_MEM_OBJECT_IMAGE1D_BUFFER:
+      if (!desc->image_width)
+         throw error(CL_INVALID_IMAGE_SIZE);
+
+      if (all_of([=](const device &dev) {
+               const size_t max = dev.max_image_buffer_size();
+               return (desc->image_width > max);
+            }, ctx.devices()))
+         throw error(CL_INVALID_IMAGE_SIZE);
+
+      return new image1d_buffer(ctx, properties, flags, format,
+                                desc->image_width,
+                                row_pitch, host_ptr, desc->buffer);
+
    case CL_MEM_OBJECT_IMAGE2D:
       if (!desc->image_width || !desc->image_height)
          throw error(CL_INVALID_IMAGE_SIZE);
@@ -287,7 +301,6 @@ clCreateImageWithProperties(cl_context d_ctx,
    }
 
    case CL_MEM_OBJECT_IMAGE1D_ARRAY:
-   case CL_MEM_OBJECT_IMAGE1D_BUFFER:
       // XXX - Not implemented.
       throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED);
 
index a59972f..6180fcf 100644 (file)
@@ -270,6 +270,16 @@ image1d::image1d(clover::context &ctx,
                row_pitch, 0, row_pitch, host_ptr, nullptr) {
 }
 
+image1d_buffer::image1d_buffer(clover::context &ctx,
+                               std::vector<cl_mem_properties> properties,
+                               cl_mem_flags flags,
+                               const cl_image_format *format,
+                               size_t width, size_t row_pitch,
+                               void *host_ptr, cl_mem buffer) :
+   basic_image(ctx, properties, flags, format, width, 1, 1, 0,
+               row_pitch, 0, row_pitch, host_ptr, buffer) {
+}
+
 image2d::image2d(clover::context &ctx,
                  std::vector<cl_mem_properties> properties,
                  cl_mem_flags flags,
index 72d9d32..fa1e53e 100644 (file)
@@ -195,6 +195,16 @@ namespace clover {
               void *host_ptr);
    };
 
+   class image1d_buffer : public basic_image<CL_MEM_OBJECT_IMAGE1D_BUFFER> {
+   public:
+      image1d_buffer(clover::context &ctx,
+                     std::vector<cl_mem_properties> properties,
+                     cl_mem_flags flags,
+                     const cl_image_format *format,
+                     size_t width, size_t row_pitch,
+                     void *host_ptr, cl_mem buffer);
+   };
+
    class image2d : public basic_image<CL_MEM_OBJECT_IMAGE2D> {
    public:
       image2d(clover::context &ctx,