clover: Implement CL_MEM_OBJECT_IMAGE1D_ARRAY
v2: Consider surface height as valid when unused by using 1.
Fixup width boundary checking.
v3 (Karol): Pull in changes from later commits
Fix validation
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:
committed by
Dave Airlie
parent
3200669c2b
commit
786987c447
@@ -242,6 +242,27 @@ clCreateImageWithProperties(cl_context d_ctx,
|
||||
desc->image_width,
|
||||
row_pitch, host_ptr, desc->buffer);
|
||||
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY: {
|
||||
if (!desc->image_width)
|
||||
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_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;
|
||||
|
||||
return new image1d_array(ctx, properties, flags, format,
|
||||
desc->image_width,
|
||||
desc->image_array_size, slice_pitch,
|
||||
host_ptr);
|
||||
}
|
||||
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
if (!desc->image_width || !desc->image_height)
|
||||
throw error(CL_INVALID_IMAGE_SIZE);
|
||||
@@ -300,10 +321,6 @@ clCreateImageWithProperties(cl_context d_ctx,
|
||||
slice_pitch, host_ptr);
|
||||
}
|
||||
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
// XXX - Not implemented.
|
||||
throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED);
|
||||
|
||||
default:
|
||||
throw error(CL_INVALID_IMAGE_DESCRIPTOR);
|
||||
}
|
||||
|
||||
@@ -104,8 +104,9 @@ namespace {
|
||||
void
|
||||
validate_object(command_queue &q, image &img,
|
||||
const vector_t &orig, const vector_t ®ion) {
|
||||
size_t height = img.type() == CL_MEM_OBJECT_IMAGE1D_ARRAY ? img.array_size() : img.height();
|
||||
size_t depth = img.type() == CL_MEM_OBJECT_IMAGE2D_ARRAY ? img.array_size() : img.depth();
|
||||
vector_t size = { img.width(), img.height(), depth };
|
||||
vector_t size = { img.width(), height, depth };
|
||||
const auto &dev = q.device();
|
||||
|
||||
if (!dev.image_support())
|
||||
@@ -127,6 +128,13 @@ namespace {
|
||||
throw error(CL_INVALID_IMAGE_SIZE);
|
||||
break;
|
||||
}
|
||||
case CL_MEM_OBJECT_IMAGE1D_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.array_size() > max_array)
|
||||
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)
|
||||
|
||||
@@ -280,6 +280,17 @@ image1d_buffer::image1d_buffer(clover::context &ctx,
|
||||
row_pitch, 0, row_pitch, host_ptr, buffer) {
|
||||
}
|
||||
|
||||
image1d_array::image1d_array(clover::context &ctx,
|
||||
std::vector<cl_mem_properties> properties,
|
||||
cl_mem_flags flags,
|
||||
const cl_image_format *format,
|
||||
size_t width,
|
||||
size_t array_size, size_t slice_pitch,
|
||||
void *host_ptr) :
|
||||
basic_image(ctx, properties, flags, format, width, 1, 1, array_size,
|
||||
0, slice_pitch, slice_pitch * array_size, host_ptr, nullptr) {
|
||||
}
|
||||
|
||||
image2d::image2d(clover::context &ctx,
|
||||
std::vector<cl_mem_properties> properties,
|
||||
cl_mem_flags flags,
|
||||
|
||||
@@ -205,6 +205,17 @@ namespace clover {
|
||||
void *host_ptr, cl_mem buffer);
|
||||
};
|
||||
|
||||
class image1d_array : public basic_image<CL_MEM_OBJECT_IMAGE1D_ARRAY> {
|
||||
public:
|
||||
image1d_array(clover::context &ctx,
|
||||
std::vector<cl_mem_properties> properties,
|
||||
cl_mem_flags flags,
|
||||
const cl_image_format *format,
|
||||
size_t width,
|
||||
size_t array_size, size_t slice_pitch,
|
||||
void *host_ptr);
|
||||
};
|
||||
|
||||
class image2d : public basic_image<CL_MEM_OBJECT_IMAGE2D> {
|
||||
public:
|
||||
image2d(clover::context &ctx,
|
||||
|
||||
Reference in New Issue
Block a user