[Mesa-dev] [PATCH 1/4] clover: Implement 'CL_MEM_OBJECT_IMAGE2D_ARRAY'
Edward O'Callaghan
funfunctor at folklore1984.net
Mon Nov 21 23:51:36 UTC 2016
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) {
+}
+
+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
More information about the mesa-dev
mailing list