diff --git a/src/gallium/frontends/clover/api/memory.cpp b/src/gallium/frontends/clover/api/memory.cpp index 2450f3f48ae..f56df7b4d45 100644 --- a/src/gallium/frontends/clover/api/memory.cpp +++ b/src/gallium/frontends/clover/api/memory.cpp @@ -454,6 +454,10 @@ clGetImageInfo(cl_mem d_mem, cl_image_info param, buf.as_scalar() = img.depth(); break; + case CL_IMAGE_ARRAY_SIZE: + buf.as_scalar() = img.array_size(); + break; + case CL_IMAGE_NUM_MIP_LEVELS: buf.as_scalar() = 0; break; diff --git a/src/gallium/frontends/clover/api/transfer.cpp b/src/gallium/frontends/clover/api/transfer.cpp index 834c47864a3..fd089fbad47 100644 --- a/src/gallium/frontends/clover/api/transfer.cpp +++ b/src/gallium/frontends/clover/api/transfer.cpp @@ -862,7 +862,7 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, if (!row_pitch) throw error(CL_INVALID_VALUE); - if (img.slice_pitch() && !slice_pitch) + if ((img.slice_pitch() || img.array_size()) && !slice_pitch) throw error(CL_INVALID_VALUE); auto *map = img.resource_in(q).add_map(q, flags, blocking, origin, region); diff --git a/src/gallium/frontends/clover/core/memory.cpp b/src/gallium/frontends/clover/core/memory.cpp index 43e37e5aaf2..c75da29fcce 100644 --- a/src/gallium/frontends/clover/core/memory.cpp +++ b/src/gallium/frontends/clover/core/memory.cpp @@ -171,12 +171,12 @@ image::image(clover::context &ctx, std::vector properties, cl_mem_flags flags, const cl_image_format *format, - size_t width, size_t height, size_t depth, + size_t width, size_t height, size_t depth, size_t array_size, size_t row_pitch, size_t slice_pitch, size_t size, void *host_ptr) : memory_obj(ctx, properties, flags, size, host_ptr), _format(*format), _width(width), _height(height), _depth(depth), - _row_pitch(row_pitch), _slice_pitch(slice_pitch) { + _row_pitch(row_pitch), _slice_pitch(slice_pitch), _array_size(array_size) { } resource & @@ -249,13 +249,18 @@ image::slice_pitch() const { return _slice_pitch; } +size_t +image::array_size() const { + return _array_size; +} + 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) : - basic_image(ctx, properties, flags, format, width, 1, 1, + basic_image(ctx, properties, flags, format, width, 1, 1, 0, row_pitch, 0, row_pitch, host_ptr) { } @@ -265,7 +270,7 @@ image2d::image2d(clover::context &ctx, const cl_image_format *format, size_t width, size_t height, size_t row_pitch, void *host_ptr) : - basic_image(ctx, properties, flags, format, width, height, 1, + basic_image(ctx, properties, flags, format, width, height, 1, 0, row_pitch, 0, height * row_pitch, host_ptr) { } @@ -276,7 +281,7 @@ image3d::image3d(clover::context &ctx, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, void *host_ptr) : - basic_image(ctx, properties, flags, format, width, height, depth, + basic_image(ctx, properties, flags, format, width, height, depth, 0, row_pitch, slice_pitch, depth * slice_pitch, host_ptr) { } diff --git a/src/gallium/frontends/clover/core/memory.hpp b/src/gallium/frontends/clover/core/memory.hpp index 34850d6b295..1c11ef98573 100644 --- a/src/gallium/frontends/clover/core/memory.hpp +++ b/src/gallium/frontends/clover/core/memory.hpp @@ -138,7 +138,7 @@ namespace clover { std::vector properties, cl_mem_flags flags, const cl_image_format *format, - size_t width, size_t height, size_t depth, + size_t width, size_t height, size_t depth, size_t array_size, size_t row_pitch, size_t slice_pitch, size_t size, void *host_ptr); @@ -150,6 +150,7 @@ namespace clover { size_t pixel_size() const; size_t row_pitch() const; size_t slice_pitch() const; + size_t array_size() const; virtual clover::resource & resource_in(command_queue &q); virtual clover::resource & @@ -167,6 +168,7 @@ namespace clover { size_t _depth; size_t _row_pitch; size_t _slice_pitch; + size_t _array_size; std::map> resources; std::mutex resources_mtx; diff --git a/src/gallium/frontends/clover/core/resource.cpp b/src/gallium/frontends/clover/core/resource.cpp index f15573f4427..484e5798639 100644 --- a/src/gallium/frontends/clover/core/resource.cpp +++ b/src/gallium/frontends/clover/core/resource.cpp @@ -164,13 +164,14 @@ root_resource::root_resource(clover::device &dev, memory_obj &obj, info.width0 = img->width(); info.height0 = img->height(); info.depth0 = img->depth(); + info.array_size = MAX2(1, img->array_size()); } else { info.width0 = obj.size(); info.height0 = 1; info.depth0 = 1; + info.array_size = 1; } - info.array_size = 1; info.target = translate_target(obj.type()); info.bind = (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_COMPUTE_RESOURCE |