diff --git a/src/gallium/frontends/clover/api/memory.cpp b/src/gallium/frontends/clover/api/memory.cpp index 6b46662ee46..743174cba30 100644 --- a/src/gallium/frontends/clover/api/memory.cpp +++ b/src/gallium/frontends/clover/api/memory.cpp @@ -214,6 +214,20 @@ clCreateImageWithProperties(cl_context d_ctx, util_format_get_blocksize(translate_format(*format)) * desc->image_width; switch (desc->image_type) { + case CL_MEM_OBJECT_IMAGE1D: + if (!desc->image_width) + throw error(CL_INVALID_IMAGE_SIZE); + + if (all_of([=](const device &dev) { + const size_t max = dev.max_image_size(); + return (desc->image_width > max); + }, ctx.devices())) + throw error(CL_INVALID_IMAGE_SIZE); + + return new image1d(ctx, properties, flags, format, + desc->image_width, + row_pitch, host_ptr); + case CL_MEM_OBJECT_IMAGE2D: if (!desc->image_width || !desc->image_height) throw error(CL_INVALID_IMAGE_SIZE); @@ -250,7 +264,6 @@ clCreateImageWithProperties(cl_context d_ctx, slice_pitch, host_ptr); } - case CL_MEM_OBJECT_IMAGE1D: case CL_MEM_OBJECT_IMAGE1D_ARRAY: case CL_MEM_OBJECT_IMAGE1D_BUFFER: case CL_MEM_OBJECT_IMAGE2D_ARRAY: diff --git a/src/gallium/frontends/clover/api/transfer.cpp b/src/gallium/frontends/clover/api/transfer.cpp index e5f89e023e1..834c47864a3 100644 --- a/src/gallium/frontends/clover/api/transfer.cpp +++ b/src/gallium/frontends/clover/api/transfer.cpp @@ -120,6 +120,12 @@ namespace { throw error(CL_INVALID_VALUE); switch (img.type()) { + case CL_MEM_OBJECT_IMAGE1D: { + const size_t max = dev.max_image_size(); + if (img.width() > max) + throw error(CL_INVALID_IMAGE_SIZE); + break; + } case CL_MEM_OBJECT_IMAGE2D: { const size_t max = dev.max_image_size(); if (img.width() > max || img.height() > max) diff --git a/src/gallium/frontends/clover/core/memory.cpp b/src/gallium/frontends/clover/core/memory.cpp index 7e2a3b921e0..54b9be7d147 100644 --- a/src/gallium/frontends/clover/core/memory.cpp +++ b/src/gallium/frontends/clover/core/memory.cpp @@ -243,6 +243,21 @@ image::slice_pitch() const { return _slice_pitch; } +image1d::image1d(clover::context &ctx, + std::vector properties, + cl_mem_flags flags, + const cl_image_format *format, + size_t width, size_t row_pitch, + void *host_ptr) : + image(ctx, properties, flags, format, width, 1, 1, + row_pitch, 0, row_pitch, host_ptr) { +} + +cl_mem_object_type +image1d::type() const { + return CL_MEM_OBJECT_IMAGE1D; +} + image2d::image2d(clover::context &ctx, std::vector properties, cl_mem_flags flags, diff --git a/src/gallium/frontends/clover/core/memory.hpp b/src/gallium/frontends/clover/core/memory.hpp index 2f827b9044d..284e86d7edc 100644 --- a/src/gallium/frontends/clover/core/memory.hpp +++ b/src/gallium/frontends/clover/core/memory.hpp @@ -169,6 +169,18 @@ namespace clover { std::unique_ptr> resources; }; + class image1d : public image { + public: + image1d(clover::context &ctx, + std::vector properties, + cl_mem_flags flags, + const cl_image_format *format, + size_t width, size_t row_pitch, + void *host_ptr); + + virtual cl_mem_object_type type() const; + }; + class image2d : public image { public: image2d(clover::context &ctx,