clover: Implement CL_MEM_OBJECT_IMAGE1D
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: Edward O'Callaghan <funfunctor@folklore1984.net> Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Francisco Jerez <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9212>
This commit is contained in:
parent
f5284a36f9
commit
44e11aa7b4
|
@ -214,6 +214,20 @@ clCreateImageWithProperties(cl_context d_ctx,
|
|||
util_format_get_blocksize(translate_format(*format)) * desc->image_width;
|
||||
|
||||
switch (desc->image_type) {
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
if (!desc->image_width)
|
||||
throw error(CL_INVALID_IMAGE_SIZE);
|
||||
|
||||
if (all_of([=](const device &dev) {
|
||||
const size_t max = dev.max_image_size();
|
||||
return (desc->image_width > max);
|
||||
}, ctx.devices()))
|
||||
throw error(CL_INVALID_IMAGE_SIZE);
|
||||
|
||||
return new image1d(ctx, properties, flags, format,
|
||||
desc->image_width,
|
||||
row_pitch, host_ptr);
|
||||
|
||||
case CL_MEM_OBJECT_IMAGE2D:
|
||||
if (!desc->image_width || !desc->image_height)
|
||||
throw error(CL_INVALID_IMAGE_SIZE);
|
||||
|
@ -250,7 +264,6 @@ clCreateImageWithProperties(cl_context d_ctx,
|
|||
slice_pitch, host_ptr);
|
||||
}
|
||||
|
||||
case CL_MEM_OBJECT_IMAGE1D:
|
||||
case CL_MEM_OBJECT_IMAGE1D_ARRAY:
|
||||
case CL_MEM_OBJECT_IMAGE1D_BUFFER:
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
|
|
|
@ -120,6 +120,12 @@ namespace {
|
|||
throw error(CL_INVALID_VALUE);
|
||||
|
||||
switch (img.type()) {
|
||||
case CL_MEM_OBJECT_IMAGE1D: {
|
||||
const size_t max = dev.max_image_size();
|
||||
if (img.width() > max)
|
||||
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)
|
||||
|
|
|
@ -243,6 +243,21 @@ image::slice_pitch() const {
|
|||
return _slice_pitch;
|
||||
}
|
||||
|
||||
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) :
|
||||
image(ctx, properties, flags, format, width, 1, 1,
|
||||
row_pitch, 0, row_pitch, host_ptr) {
|
||||
}
|
||||
|
||||
cl_mem_object_type
|
||||
image1d::type() const {
|
||||
return CL_MEM_OBJECT_IMAGE1D;
|
||||
}
|
||||
|
||||
image2d::image2d(clover::context &ctx,
|
||||
std::vector<cl_mem_properties> properties,
|
||||
cl_mem_flags flags,
|
||||
|
|
|
@ -169,6 +169,18 @@ namespace clover {
|
|||
std::unique_ptr<root_resource>> resources;
|
||||
};
|
||||
|
||||
class image1d : public image {
|
||||
public:
|
||||
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);
|
||||
|
||||
virtual cl_mem_object_type type() const;
|
||||
};
|
||||
|
||||
class image2d : public image {
|
||||
public:
|
||||
image2d(clover::context &ctx,
|
||||
|
|
Loading…
Reference in New Issue