summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <funfunctor@folklore1984.net>2016-11-26 17:18:58 +1100
committerDave Airlie <airlied@redhat.com>2021-10-18 12:22:21 +1000
commit3298ee546e85f80d63ccee9f81a92b0f075232af (patch)
treec129ed2337c32da438c0e3aa1c16a4ad0e8fccc2
parent029f22e430f74a5d26eb7e69a08fe703ccc4e77a (diff)
clover/images: Add array_size to implement CL_IMAGE_ARRAY_SIZE
This will be needed to implement array immages. v2 (Karol Herbst): Extracted from other commit Fix clEnqueueMapImage for arrays Add some basic support for image arrays 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>
-rw-r--r--src/gallium/frontends/clover/api/memory.cpp4
-rw-r--r--src/gallium/frontends/clover/api/transfer.cpp2
-rw-r--r--src/gallium/frontends/clover/core/memory.cpp15
-rw-r--r--src/gallium/frontends/clover/core/memory.hpp4
-rw-r--r--src/gallium/frontends/clover/core/resource.cpp3
5 files changed, 20 insertions, 8 deletions
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<size_t>() = img.depth();
break;
+ case CL_IMAGE_ARRAY_SIZE:
+ buf.as_scalar<size_t>() = img.array_size();
+ break;
+
case CL_IMAGE_NUM_MIP_LEVELS:
buf.as_scalar<cl_uint>() = 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<cl_mem_properties> 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<cl_mem_properties> 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<cl_mem_properties> 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<device *,
std::unique_ptr<root_resource>> 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 |