clover: Implement CL_MEM_OBJECT_IMAGE2D_ARRAY

v2: Ensure we pass in row_pitch state as well.
v3 (Karol): Pull in changes from later commits

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>
This commit is contained in:
Edward O'Callaghan 2016-11-18 15:24:18 +11:00 committed by Dave Airlie
parent 0abfbb76ff
commit 0ec5e50d8a
4 changed files with 53 additions and 2 deletions

View file

@ -243,6 +243,28 @@ clCreateImageWithProperties(cl_context d_ctx,
desc->image_width, desc->image_height,
row_pitch, host_ptr);
case CL_MEM_OBJECT_IMAGE2D_ARRAY: {
if (!desc->image_width || !desc->image_height || !desc->image_array_size)
throw error(CL_INVALID_IMAGE_SIZE);
if (all_of([=](const device &dev) {
const size_t max = dev.max_image_size();
const size_t amax = dev.max_image_array_number();
return (desc->image_width > max ||
desc->image_height > max ||
desc->image_array_size > amax);
}, ctx.devices()))
throw error(CL_INVALID_IMAGE_SIZE);
const size_t slice_pitch = desc->image_slice_pitch ?
desc->image_slice_pitch : row_pitch * desc->image_height;
return new image2d_array(ctx, properties, flags, format,
desc->image_width, desc->image_height,
desc->image_array_size, row_pitch,
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);
@ -266,7 +288,6 @@ clCreateImageWithProperties(cl_context d_ctx,
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);

View file

@ -104,7 +104,8 @@ namespace {
void
validate_object(command_queue &q, image &img,
const vector_t &orig, const vector_t &region) {
vector_t size = { img.width(), img.height(), img.depth() };
size_t depth = img.type() == CL_MEM_OBJECT_IMAGE2D_ARRAY ? img.array_size() : img.depth();
vector_t size = { img.width(), img.height(), depth };
const auto &dev = q.device();
if (!dev.image_support())
@ -132,6 +133,13 @@ namespace {
throw error(CL_INVALID_IMAGE_SIZE);
break;
}
case CL_MEM_OBJECT_IMAGE2D_ARRAY: {
const size_t max_size = dev.max_image_size();
const size_t max_array = dev.max_image_array_number();
if (img.width() > max_size || img.height() > max_size || img.array_size() > max_array)
throw error(CL_INVALID_IMAGE_SIZE);
break;
}
case CL_MEM_OBJECT_IMAGE3D: {
const size_t max = dev.max_image_size_3d();
if (img.width() > max || img.height() > max || img.depth() > max)

View file

@ -280,6 +280,17 @@ image2d::image2d(clover::context &ctx,
row_pitch, 0, height * row_pitch, host_ptr, nullptr) {
}
image2d_array::image2d_array(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 array_size,
size_t row_pitch, size_t slice_pitch,
void *host_ptr) :
basic_image(ctx, properties, flags, format, width, height, 1, array_size,
row_pitch, slice_pitch, slice_pitch * array_size, host_ptr, nullptr) {
}
image3d::image3d(clover::context &ctx,
std::vector<cl_mem_properties> properties,
cl_mem_flags flags,

View file

@ -205,6 +205,17 @@ namespace clover {
void *host_ptr);
};
class image2d_array : public basic_image<CL_MEM_OBJECT_IMAGE2D_ARRAY> {
public:
image2d_array(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 array_size,
size_t row_pitch, size_t slice_pitch,
void *host_ptr);
};
class image3d : public basic_image<CL_MEM_OBJECT_IMAGE3D>{
public:
image3d(clover::context &ctx,