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>
This commit is contained in:
Edward O'Callaghan 2016-11-26 17:18:58 +11:00 committed by Dave Airlie
parent 029f22e430
commit 3298ee546e
5 changed files with 20 additions and 8 deletions

View File

@ -454,6 +454,10 @@ clGetImageInfo(cl_mem d_mem, cl_image_info param,
buf.as_scalar<size_t>() = img.depth(); buf.as_scalar<size_t>() = img.depth();
break; break;
case CL_IMAGE_ARRAY_SIZE:
buf.as_scalar<size_t>() = img.array_size();
break;
case CL_IMAGE_NUM_MIP_LEVELS: case CL_IMAGE_NUM_MIP_LEVELS:
buf.as_scalar<cl_uint>() = 0; buf.as_scalar<cl_uint>() = 0;
break; break;

View File

@ -862,7 +862,7 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking,
if (!row_pitch) if (!row_pitch)
throw error(CL_INVALID_VALUE); 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); throw error(CL_INVALID_VALUE);
auto *map = img.resource_in(q).add_map(q, flags, blocking, origin, region); auto *map = img.resource_in(q).add_map(q, flags, blocking, origin, region);

View File

@ -171,12 +171,12 @@ image::image(clover::context &ctx,
std::vector<cl_mem_properties> properties, std::vector<cl_mem_properties> properties,
cl_mem_flags flags, cl_mem_flags flags,
const cl_image_format *format, 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, size_t row_pitch, size_t slice_pitch, size_t size,
void *host_ptr) : void *host_ptr) :
memory_obj(ctx, properties, flags, size, host_ptr), memory_obj(ctx, properties, flags, size, host_ptr),
_format(*format), _width(width), _height(height), _depth(depth), _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 & resource &
@ -249,13 +249,18 @@ image::slice_pitch() const {
return _slice_pitch; return _slice_pitch;
} }
size_t
image::array_size() const {
return _array_size;
}
image1d::image1d(clover::context &ctx, image1d::image1d(clover::context &ctx,
std::vector<cl_mem_properties> properties, std::vector<cl_mem_properties> properties,
cl_mem_flags flags, cl_mem_flags flags,
const cl_image_format *format, const cl_image_format *format,
size_t width, size_t row_pitch, size_t width, size_t row_pitch,
void *host_ptr) : 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) { row_pitch, 0, row_pitch, host_ptr) {
} }
@ -265,7 +270,7 @@ image2d::image2d(clover::context &ctx,
const cl_image_format *format, size_t width, const cl_image_format *format, size_t width,
size_t height, size_t row_pitch, size_t height, size_t row_pitch,
void *host_ptr) : 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) { 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 width, size_t height, size_t depth,
size_t row_pitch, size_t slice_pitch, size_t row_pitch, size_t slice_pitch,
void *host_ptr) : 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, row_pitch, slice_pitch, depth * slice_pitch,
host_ptr) { host_ptr) {
} }

View File

@ -138,7 +138,7 @@ namespace clover {
std::vector<cl_mem_properties> properties, std::vector<cl_mem_properties> properties,
cl_mem_flags flags, cl_mem_flags flags,
const cl_image_format *format, 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, size_t row_pitch, size_t slice_pitch, size_t size,
void *host_ptr); void *host_ptr);
@ -150,6 +150,7 @@ namespace clover {
size_t pixel_size() const; size_t pixel_size() const;
size_t row_pitch() const; size_t row_pitch() const;
size_t slice_pitch() const; size_t slice_pitch() const;
size_t array_size() const;
virtual clover::resource & virtual clover::resource &
resource_in(command_queue &q); resource_in(command_queue &q);
virtual clover::resource & virtual clover::resource &
@ -167,6 +168,7 @@ namespace clover {
size_t _depth; size_t _depth;
size_t _row_pitch; size_t _row_pitch;
size_t _slice_pitch; size_t _slice_pitch;
size_t _array_size;
std::map<device *, std::map<device *,
std::unique_ptr<root_resource>> resources; std::unique_ptr<root_resource>> resources;
std::mutex resources_mtx; std::mutex resources_mtx;

View File

@ -164,13 +164,14 @@ root_resource::root_resource(clover::device &dev, memory_obj &obj,
info.width0 = img->width(); info.width0 = img->width();
info.height0 = img->height(); info.height0 = img->height();
info.depth0 = img->depth(); info.depth0 = img->depth();
info.array_size = MAX2(1, img->array_size());
} else { } else {
info.width0 = obj.size(); info.width0 = obj.size();
info.height0 = 1; info.height0 = 1;
info.depth0 = 1; info.depth0 = 1;
info.array_size = 1;
} }
info.array_size = 1;
info.target = translate_target(obj.type()); info.target = translate_target(obj.type());
info.bind = (PIPE_BIND_SAMPLER_VIEW | info.bind = (PIPE_BIND_SAMPLER_VIEW |
PIPE_BIND_COMPUTE_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE |