diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/clover/api/memory.cpp | 144 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/api/transfer.cpp | 234 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/error.hpp | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/kernel.cpp | 20 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/memory.cpp | 32 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/memory.hpp | 92 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/object.hpp | 3 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/resource.cpp | 20 | ||||
-rw-r--r-- | src/gallium/state_trackers/clover/core/resource.hpp | 22 |
9 files changed, 267 insertions, 302 deletions
diff --git a/src/gallium/state_trackers/clover/api/memory.cpp b/src/gallium/state_trackers/clover/api/memory.cpp index b6b82f8d425..b01a1bc5bd1 100644 --- a/src/gallium/state_trackers/clover/api/memory.cpp +++ b/src/gallium/state_trackers/clover/api/memory.cpp @@ -27,10 +27,9 @@ using namespace clover; PUBLIC cl_mem -clCreateBuffer(cl_context ctx, cl_mem_flags flags, size_t size, - void *host_ptr, cl_int *errcode_ret) try { - if (!ctx) - throw error(CL_INVALID_CONTEXT); +clCreateBuffer(cl_context d_ctx, cl_mem_flags flags, size_t size, + void *host_ptr, cl_int *r_errcode) try { + auto &ctx = obj(d_ctx); if (bool(host_ptr) != bool(flags & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR))) @@ -44,49 +43,47 @@ clCreateBuffer(cl_context ctx, cl_mem_flags flags, size_t size, CL_MEM_COPY_HOST_PTR)) throw error(CL_INVALID_VALUE); - ret_error(errcode_ret, CL_SUCCESS); - return new root_buffer(obj(ctx), flags, size, host_ptr); + ret_error(r_errcode, CL_SUCCESS); + return new root_buffer(ctx, flags, size, host_ptr); } catch (error &e) { - ret_error(errcode_ret, e); + ret_error(r_errcode, e); return NULL; } PUBLIC cl_mem -clCreateSubBuffer(cl_mem obj, cl_mem_flags flags, cl_buffer_create_type op, - const void *op_info, cl_int *errcode_ret) try { - root_buffer *parent = dynamic_cast<root_buffer *>(obj); - - if (!parent) - throw error(CL_INVALID_MEM_OBJECT); +clCreateSubBuffer(cl_mem d_mem, cl_mem_flags flags, + cl_buffer_create_type op, + const void *op_info, cl_int *r_errcode) try { + auto &parent = obj<root_buffer>(d_mem); if ((flags & (CL_MEM_USE_HOST_PTR | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR)) || - (~flags & parent->flags() & (CL_MEM_READ_ONLY | - CL_MEM_WRITE_ONLY))) + (~flags & parent.flags() & (CL_MEM_READ_ONLY | + CL_MEM_WRITE_ONLY))) throw error(CL_INVALID_VALUE); if (op == CL_BUFFER_CREATE_TYPE_REGION) { - const cl_buffer_region *reg = (const cl_buffer_region *)op_info; + auto reg = reinterpret_cast<const cl_buffer_region *>(op_info); if (!reg || - reg->origin > parent->size() || - reg->origin + reg->size > parent->size()) + reg->origin > parent.size() || + reg->origin + reg->size > parent.size()) throw error(CL_INVALID_VALUE); if (!reg->size) throw error(CL_INVALID_BUFFER_SIZE); - ret_error(errcode_ret, CL_SUCCESS); - return new sub_buffer(*parent, flags, reg->origin, reg->size); + ret_error(r_errcode, CL_SUCCESS); + return new sub_buffer(parent, flags, reg->origin, reg->size); } else { throw error(CL_INVALID_VALUE); } } catch (error &e) { - ret_error(errcode_ret, e); + ret_error(r_errcode, e); return NULL; } @@ -94,7 +91,7 @@ PUBLIC cl_mem clCreateImage2D(cl_context d_ctx, cl_mem_flags flags, const cl_image_format *format, size_t width, size_t height, size_t row_pitch, - void *host_ptr, cl_int *errcode_ret) try { + void *host_ptr, cl_int *r_errcode) try { auto &ctx = obj(d_ctx); if (flags & ~(CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | @@ -115,12 +112,12 @@ clCreateImage2D(cl_context d_ctx, cl_mem_flags flags, if (!supported_formats(ctx, CL_MEM_OBJECT_IMAGE2D).count(*format)) throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED); - ret_error(errcode_ret, CL_SUCCESS); + ret_error(r_errcode, CL_SUCCESS); return new image2d(ctx, flags, format, width, height, row_pitch, host_ptr); } catch (error &e) { - ret_error(errcode_ret, e); + ret_error(r_errcode, e); return NULL; } @@ -129,7 +126,7 @@ clCreateImage3D(cl_context d_ctx, cl_mem_flags flags, const cl_image_format *format, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, - void *host_ptr, cl_int *errcode_ret) try { + void *host_ptr, cl_int *r_errcode) try { auto &ctx = obj(d_ctx); if (flags & ~(CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | @@ -150,19 +147,19 @@ clCreateImage3D(cl_context d_ctx, cl_mem_flags flags, if (!supported_formats(ctx, CL_MEM_OBJECT_IMAGE3D).count(*format)) throw error(CL_IMAGE_FORMAT_NOT_SUPPORTED); - ret_error(errcode_ret, CL_SUCCESS); + ret_error(r_errcode, CL_SUCCESS); return new image3d(ctx, flags, format, width, height, depth, row_pitch, slice_pitch, host_ptr); } catch (error &e) { - ret_error(errcode_ret, e); + ret_error(r_errcode, e); return NULL; } PUBLIC cl_int clGetSupportedImageFormats(cl_context d_ctx, cl_mem_flags flags, cl_mem_object_type type, cl_uint count, - cl_image_format *buf, cl_uint *count_ret) try { + cl_image_format *r_buf, cl_uint *r_count) try { auto &ctx = obj(d_ctx); if (flags & ~(CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | @@ -170,16 +167,18 @@ clGetSupportedImageFormats(cl_context d_ctx, cl_mem_flags flags, CL_MEM_COPY_HOST_PTR)) throw error(CL_INVALID_VALUE); - if (!count && buf) + if (r_buf && !r_count) throw error(CL_INVALID_VALUE); auto formats = supported_formats(ctx, type); - if (buf) - std::copy_n(formats.begin(), std::min((cl_uint)formats.size(), count), - buf); - if (count_ret) - *count_ret = formats.size(); + if (r_buf) + std::copy_n(formats.begin(), + std::min((cl_uint)formats.size(), count), + r_buf); + + if (r_count) + *r_count = formats.size(); return CL_SUCCESS; @@ -188,28 +187,26 @@ clGetSupportedImageFormats(cl_context d_ctx, cl_mem_flags flags, } PUBLIC cl_int -clGetMemObjectInfo(cl_mem obj, cl_mem_info param, +clGetMemObjectInfo(cl_mem d_mem, cl_mem_info param, size_t size, void *r_buf, size_t *r_size) try { property_buffer buf { r_buf, size, r_size }; - - if (!obj) - return CL_INVALID_MEM_OBJECT; + auto &mem = obj(d_mem); switch (param) { case CL_MEM_TYPE: - buf.as_scalar<cl_mem_object_type>() = obj->type(); + buf.as_scalar<cl_mem_object_type>() = mem.type(); break; case CL_MEM_FLAGS: - buf.as_scalar<cl_mem_flags>() = obj->flags(); + buf.as_scalar<cl_mem_flags>() = mem.flags(); break; case CL_MEM_SIZE: - buf.as_scalar<size_t>() = obj->size(); + buf.as_scalar<size_t>() = mem.size(); break; case CL_MEM_HOST_PTR: - buf.as_scalar<void *>() = obj->host_ptr(); + buf.as_scalar<void *>() = mem.host_ptr(); break; case CL_MEM_MAP_COUNT: @@ -217,20 +214,20 @@ clGetMemObjectInfo(cl_mem obj, cl_mem_info param, break; case CL_MEM_REFERENCE_COUNT: - buf.as_scalar<cl_uint>() = obj->ref_count(); + buf.as_scalar<cl_uint>() = mem.ref_count(); break; case CL_MEM_CONTEXT: - buf.as_scalar<cl_context>() = &obj->ctx; + buf.as_scalar<cl_context>() = desc(mem.ctx); break; case CL_MEM_ASSOCIATED_MEMOBJECT: { - sub_buffer *sub = dynamic_cast<sub_buffer *>(obj); - buf.as_scalar<cl_mem>() = (sub ? &sub->parent : NULL); + sub_buffer *sub = dynamic_cast<sub_buffer *>(&mem); + buf.as_scalar<cl_mem>() = (sub ? desc(sub->parent) : NULL); break; } case CL_MEM_OFFSET: { - sub_buffer *sub = dynamic_cast<sub_buffer *>(obj); + sub_buffer *sub = dynamic_cast<sub_buffer *>(&mem); buf.as_scalar<size_t>() = (sub ? sub->offset() : 0); break; } @@ -245,17 +242,14 @@ clGetMemObjectInfo(cl_mem obj, cl_mem_info param, } PUBLIC cl_int -clGetImageInfo(cl_mem obj, cl_image_info param, +clGetImageInfo(cl_mem d_mem, cl_image_info param, size_t size, void *r_buf, size_t *r_size) try { property_buffer buf { r_buf, size, r_size }; - image *img = dynamic_cast<image *>(obj); - - if (!img) - return CL_INVALID_MEM_OBJECT; + auto &img = obj<image>(d_mem); switch (param) { case CL_IMAGE_FORMAT: - buf.as_scalar<cl_image_format>() = img->format(); + buf.as_scalar<cl_image_format>() = img.format(); break; case CL_IMAGE_ELEMENT_SIZE: @@ -263,23 +257,23 @@ clGetImageInfo(cl_mem obj, cl_image_info param, break; case CL_IMAGE_ROW_PITCH: - buf.as_scalar<size_t>() = img->row_pitch(); + buf.as_scalar<size_t>() = img.row_pitch(); break; case CL_IMAGE_SLICE_PITCH: - buf.as_scalar<size_t>() = img->slice_pitch(); + buf.as_scalar<size_t>() = img.slice_pitch(); break; case CL_IMAGE_WIDTH: - buf.as_scalar<size_t>() = img->width(); + buf.as_scalar<size_t>() = img.width(); break; case CL_IMAGE_HEIGHT: - buf.as_scalar<size_t>() = img->height(); + buf.as_scalar<size_t>() = img.height(); break; case CL_IMAGE_DEPTH: - buf.as_scalar<size_t>() = img->depth(); + buf.as_scalar<size_t>() = img.depth(); break; default: @@ -293,36 +287,38 @@ clGetImageInfo(cl_mem obj, cl_image_info param, } PUBLIC cl_int -clRetainMemObject(cl_mem obj) { - if (!obj) - return CL_INVALID_MEM_OBJECT; - - obj->retain(); +clRetainMemObject(cl_mem d_mem) try { + obj(d_mem).retain(); return CL_SUCCESS; + +} catch (error &e) { + return e.get(); } PUBLIC cl_int -clReleaseMemObject(cl_mem obj) { - if (!obj) - return CL_INVALID_MEM_OBJECT; - - if (obj->release()) - delete obj; +clReleaseMemObject(cl_mem d_mem) try { + if (obj(d_mem).release()) + delete pobj(d_mem); return CL_SUCCESS; + +} catch (error &e) { + return e.get(); } PUBLIC cl_int -clSetMemObjectDestructorCallback(cl_mem obj, +clSetMemObjectDestructorCallback(cl_mem d_mem, void (CL_CALLBACK *pfn_notify)(cl_mem, void *), - void *user_data) { - if (!obj) - return CL_INVALID_MEM_OBJECT; + void *user_data) try { + auto &mem = obj(d_mem); if (!pfn_notify) return CL_INVALID_VALUE; - obj->destroy_notify([=]{ pfn_notify(obj, user_data); }); + mem.destroy_notify([=]{ pfn_notify(d_mem, user_data); }); return CL_SUCCESS; + +} catch (error &e) { + return e.get(); } diff --git a/src/gallium/state_trackers/clover/api/transfer.cpp b/src/gallium/state_trackers/clover/api/transfer.cpp index f91da617b68..e6fa26ca4e4 100644 --- a/src/gallium/state_trackers/clover/api/transfer.cpp +++ b/src/gallium/state_trackers/clover/api/transfer.cpp @@ -40,27 +40,17 @@ namespace { /// Common argument checking shared by memory transfer commands. /// void - validate_base(command_queue &q, cl_uint num_deps, const cl_event *deps) { - if (bool(num_deps) != bool(deps) || - any_of(is_zero(), range(deps, num_deps))) - throw error(CL_INVALID_EVENT_WAIT_LIST); - - if (any_of([&](const cl_event ev) { - return &obj(ev).ctx != &q.ctx; - }, range(deps, num_deps))) + validate_common(command_queue &q, + std::initializer_list<std::reference_wrapper<memory_obj>> mems, + const ref_vector<event> &deps) { + if (any_of([&](const event &ev) { + return &ev.ctx != &q.ctx; + }, deps)) throw error(CL_INVALID_CONTEXT); - } - /// - /// Memory object-specific argument checking shared by most memory - /// transfer commands. - /// - void - validate_obj(command_queue &q, cl_mem mem) { - if (!mem) - throw error(CL_INVALID_MEM_OBJECT); - - if (&mem->ctx != &q.ctx) + if (any_of([&](const memory_obj &mem) { + return &mem.ctx != &q.ctx; + }, mems)) throw error(CL_INVALID_CONTEXT); } @@ -69,44 +59,45 @@ namespace { /// \a T. The return value of get() should be implicitly /// convertible to \a void *. /// - template<typename T> struct _map; + template<typename T> + struct _map { + static mapping + get(command_queue &q, T obj, cl_map_flags flags, + size_t offset, size_t size) { + return { q, obj->resource(q), flags, true, + {{ offset }}, {{ size, 1, 1 }} }; + } + }; - template<> struct _map<void *> { + template<> + struct _map<void *> { static void * - get(cl_command_queue q, void *obj, cl_map_flags flags, + get(command_queue &q, void *obj, cl_map_flags flags, size_t offset, size_t size) { return (char *)obj + offset; } }; - template<> struct _map<const void *> { + template<> + struct _map<const void *> { static const void * - get(cl_command_queue q, const void *obj, cl_map_flags flags, + get(command_queue &q, const void *obj, cl_map_flags flags, size_t offset, size_t size) { return (const char *)obj + offset; } }; - template<> struct _map<memory_obj *> { - static mapping - get(cl_command_queue q, memory_obj *mem, cl_map_flags flags, - size_t offset, size_t size) {< - return { obj(q), mem->resource(obj(q)), flags, true, - {{ offset }}, {{ size, 1, 1 }}}; - } - }; - /// /// Software copy from \a src_obj to \a dst_obj. They can be /// either pointers or memory objects. /// template<typename T, typename S> std::function<void (event &)> - soft_copy_op(cl_command_queue q, + soft_copy_op(command_queue &q, T dst_obj, const vector_t &dst_orig, const vector_t &dst_pitch, S src_obj, const vector_t &src_orig, const vector_t &src_pitch, const vector_t ®ion) { - return [=](event &) { + return [=, &q](event &) { auto dst = _map<T>::get(q, dst_obj, CL_MAP_WRITE, dot(dst_pitch, dst_orig), dst_pitch[2] * region[2]); @@ -141,24 +132,24 @@ namespace { } PUBLIC cl_int -clEnqueueReadBuffer(cl_command_queue d_q, cl_mem mem, cl_bool blocking, +clEnqueueReadBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, size_t offset, size_t size, void *ptr, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &mem = obj(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - validate_base(q, num_deps, d_deps); - validate_obj(q, mem); + validate_common(q, { mem }, deps); - if (!ptr || offset > mem->size() || offset + size > mem->size()) + if (!ptr || offset > mem.size() || offset + size > mem.size()) throw error(CL_INVALID_VALUE); hard_event *hev = new hard_event( q, CL_COMMAND_READ_BUFFER, deps, - soft_copy_op(d_q, + soft_copy_op(q, ptr, {{ 0 }}, {{ 1 }}, - mem, {{ offset }}, {{ 1 }}, + &mem, {{ offset }}, {{ 1 }}, {{ size, 1, 1 }})); ret_object(rd_ev, hev); @@ -169,23 +160,23 @@ clEnqueueReadBuffer(cl_command_queue d_q, cl_mem mem, cl_bool blocking, } PUBLIC cl_int -clEnqueueWriteBuffer(cl_command_queue d_q, cl_mem mem, cl_bool blocking, +clEnqueueWriteBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, size_t offset, size_t size, const void *ptr, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &mem = obj(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - validate_base(q, num_deps, d_deps); - validate_obj(q, mem); + validate_common(q, { mem }, deps); - if (!ptr || offset > mem->size() || offset + size > mem->size()) + if (!ptr || offset > mem.size() || offset + size > mem.size()) throw error(CL_INVALID_VALUE); hard_event *hev = new hard_event( q, CL_COMMAND_WRITE_BUFFER, deps, - soft_copy_op(d_q, - mem, {{ offset }}, {{ 1 }}, + soft_copy_op(q, + &mem, {{ offset }}, {{ 1 }}, ptr, {{ 0 }}, {{ 1 }}, {{ size, 1, 1 }})); @@ -197,7 +188,7 @@ clEnqueueWriteBuffer(cl_command_queue d_q, cl_mem mem, cl_bool blocking, } PUBLIC cl_int -clEnqueueReadBufferRect(cl_command_queue d_q, cl_mem mem, cl_bool blocking, +clEnqueueReadBufferRect(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, const size_t *obj_origin, const size_t *host_origin, const size_t *region, @@ -207,20 +198,20 @@ clEnqueueReadBufferRect(cl_command_queue d_q, cl_mem mem, cl_bool blocking, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &mem = obj(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - validate_base(q, num_deps, d_deps); - validate_obj(q, mem); + validate_common(q, { mem }, deps); if (!ptr) throw error(CL_INVALID_VALUE); hard_event *hev = new hard_event( q, CL_COMMAND_READ_BUFFER_RECT, deps, - soft_copy_op(d_q, + soft_copy_op(q, ptr, vector(host_origin), {{ 1, host_row_pitch, host_slice_pitch }}, - mem, vector(obj_origin), + &mem, vector(obj_origin), {{ 1, obj_row_pitch, obj_slice_pitch }}, vector(region))); @@ -232,7 +223,7 @@ clEnqueueReadBufferRect(cl_command_queue d_q, cl_mem mem, cl_bool blocking, } PUBLIC cl_int -clEnqueueWriteBufferRect(cl_command_queue d_q, cl_mem mem, cl_bool blocking, +clEnqueueWriteBufferRect(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, const size_t *obj_origin, const size_t *host_origin, const size_t *region, @@ -242,18 +233,18 @@ clEnqueueWriteBufferRect(cl_command_queue d_q, cl_mem mem, cl_bool blocking, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &mem = obj(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - validate_base(q, num_deps, d_deps); - validate_obj(q, mem); + validate_common(q, { mem }, deps); if (!ptr) throw error(CL_INVALID_VALUE); hard_event *hev = new hard_event( q, CL_COMMAND_WRITE_BUFFER_RECT, deps, - soft_copy_op(d_q, - mem, vector(obj_origin), + soft_copy_op(q, + &mem, vector(obj_origin), {{ 1, obj_row_pitch, obj_slice_pitch }}, ptr, vector(host_origin), {{ 1, host_row_pitch, host_slice_pitch }}, @@ -267,21 +258,21 @@ clEnqueueWriteBufferRect(cl_command_queue d_q, cl_mem mem, cl_bool blocking, } PUBLIC cl_int -clEnqueueCopyBuffer(cl_command_queue d_q, cl_mem src_mem, cl_mem dst_mem, +clEnqueueCopyBuffer(cl_command_queue d_q, cl_mem d_src_mem, cl_mem d_dst_mem, size_t src_offset, size_t dst_offset, size_t size, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &src_mem = obj(d_src_mem); + auto &dst_mem = obj(d_dst_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - validate_base(q, num_deps, d_deps); - validate_obj(q, src_mem); - validate_obj(q, dst_mem); + validate_common(q, { src_mem, dst_mem }, deps); hard_event *hev = new hard_event( q, CL_COMMAND_COPY_BUFFER, deps, - hard_copy_op(q, dst_mem, {{ dst_offset }}, - src_mem, {{ src_offset }}, + hard_copy_op(q, &dst_mem, {{ dst_offset }}, + &src_mem, {{ src_offset }}, {{ size, 1, 1 }})); ret_object(rd_ev, hev); @@ -292,8 +283,8 @@ clEnqueueCopyBuffer(cl_command_queue d_q, cl_mem src_mem, cl_mem dst_mem, } PUBLIC cl_int -clEnqueueCopyBufferRect(cl_command_queue d_q, cl_mem src_mem, - cl_mem dst_mem, +clEnqueueCopyBufferRect(cl_command_queue d_q, cl_mem d_src_mem, + cl_mem d_dst_mem, const size_t *src_origin, const size_t *dst_origin, const size_t *region, size_t src_row_pitch, size_t src_slice_pitch, @@ -301,18 +292,18 @@ clEnqueueCopyBufferRect(cl_command_queue d_q, cl_mem src_mem, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &src_mem = obj(d_src_mem); + auto &dst_mem = obj(d_dst_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - validate_base(q, num_deps, d_deps); - validate_obj(q, src_mem); - validate_obj(q, dst_mem); + validate_common(q, { src_mem, dst_mem }, deps); hard_event *hev = new hard_event( q, CL_COMMAND_COPY_BUFFER_RECT, deps, - soft_copy_op(d_q, - dst_mem, vector(dst_origin), + soft_copy_op(q, + &dst_mem, vector(dst_origin), {{ 1, dst_row_pitch, dst_slice_pitch }}, - src_mem, vector(src_origin), + &src_mem, vector(src_origin), {{ 1, src_row_pitch, src_slice_pitch }}, vector(region))); @@ -324,28 +315,27 @@ clEnqueueCopyBufferRect(cl_command_queue d_q, cl_mem src_mem, } PUBLIC cl_int -clEnqueueReadImage(cl_command_queue d_q, cl_mem mem, cl_bool blocking, +clEnqueueReadImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, const size_t *origin, const size_t *region, size_t row_pitch, size_t slice_pitch, void *ptr, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &img = obj<image>(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - image *img = dynamic_cast<image *>(mem); - validate_base(q, num_deps, d_deps); - validate_obj(q, img); + validate_common(q, { img }, deps); if (!ptr) throw error(CL_INVALID_VALUE); hard_event *hev = new hard_event( q, CL_COMMAND_READ_IMAGE, deps, - soft_copy_op(d_q, + soft_copy_op(q, ptr, {}, {{ 1, row_pitch, slice_pitch }}, - mem, vector(origin), - {{ 1, img->row_pitch(), img->slice_pitch() }}, + &img, vector(origin), + {{ 1, img.row_pitch(), img.slice_pitch() }}, vector(region))); ret_object(rd_ev, hev); @@ -356,26 +346,25 @@ clEnqueueReadImage(cl_command_queue d_q, cl_mem mem, cl_bool blocking, } PUBLIC cl_int -clEnqueueWriteImage(cl_command_queue d_q, cl_mem mem, cl_bool blocking, +clEnqueueWriteImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, const size_t *origin, const size_t *region, size_t row_pitch, size_t slice_pitch, const void *ptr, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &img = obj<image>(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - image *img = dynamic_cast<image *>(mem); - validate_base(q, num_deps, d_deps); - validate_obj(q, img); + validate_common(q, { img }, deps); if (!ptr) throw error(CL_INVALID_VALUE); hard_event *hev = new hard_event( q, CL_COMMAND_WRITE_IMAGE, deps, - soft_copy_op(d_q, - mem, vector(origin), - {{ 1, img->row_pitch(), img->slice_pitch() }}, + soft_copy_op(q, + &img, vector(origin), + {{ 1, img.row_pitch(), img.slice_pitch() }}, ptr, {}, {{ 1, row_pitch, slice_pitch }}, vector(region))); @@ -388,25 +377,23 @@ clEnqueueWriteImage(cl_command_queue d_q, cl_mem mem, cl_bool blocking, } PUBLIC cl_int -clEnqueueCopyImage(cl_command_queue d_q, cl_mem src_mem, cl_mem dst_mem, +clEnqueueCopyImage(cl_command_queue d_q, cl_mem d_src_mem, cl_mem d_dst_mem, const size_t *src_origin, const size_t *dst_origin, const size_t *region, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &src_img = obj<image>(d_src_mem); + auto &dst_img = obj<image>(d_dst_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - image *src_img = dynamic_cast<image *>(src_mem); - image *dst_img = dynamic_cast<image *>(dst_mem); - validate_base(q, num_deps, d_deps); - validate_obj(q, src_img); - validate_obj(q, dst_img); + validate_common(q, { src_img, dst_img }, deps); hard_event *hev = new hard_event( q, CL_COMMAND_COPY_IMAGE, deps, hard_copy_op(q, - dst_img, vector(dst_origin), - src_img, vector(src_origin), + &dst_img, vector(dst_origin), + &src_img, vector(src_origin), vector(region))); ret_object(rd_ev, hev); @@ -418,26 +405,25 @@ clEnqueueCopyImage(cl_command_queue d_q, cl_mem src_mem, cl_mem dst_mem, PUBLIC cl_int clEnqueueCopyImageToBuffer(cl_command_queue d_q, - cl_mem src_mem, cl_mem dst_mem, + cl_mem d_src_mem, cl_mem d_dst_mem, const size_t *src_origin, const size_t *region, size_t dst_offset, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &src_img = obj<image>(d_src_mem); + auto &dst_mem = obj(d_dst_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - image *src_img = dynamic_cast<image *>(src_mem); - validate_base(q, num_deps, d_deps); - validate_obj(q, src_img); - validate_obj(q, dst_mem); + validate_common(q, { src_img, dst_mem }, deps); hard_event *hev = new hard_event( q, CL_COMMAND_COPY_IMAGE_TO_BUFFER, deps, - soft_copy_op(d_q, - dst_mem, {{ dst_offset }}, + soft_copy_op(q, + &dst_mem, {{ dst_offset }}, {{ 0, 0, 0 }}, - src_mem, vector(src_origin), - {{ 1, src_img->row_pitch(), src_img->slice_pitch() }}, + &src_img, vector(src_origin), + {{ 1, src_img.row_pitch(), src_img.slice_pitch() }}, vector(region))); ret_object(rd_ev, hev); @@ -449,25 +435,24 @@ clEnqueueCopyImageToBuffer(cl_command_queue d_q, PUBLIC cl_int clEnqueueCopyBufferToImage(cl_command_queue d_q, - cl_mem src_mem, cl_mem dst_mem, + cl_mem d_src_mem, cl_mem d_dst_mem, size_t src_offset, const size_t *dst_origin, const size_t *region, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &src_mem = obj(d_src_mem); + auto &dst_img = obj<image>(d_dst_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - image *dst_img = dynamic_cast<image *>(dst_mem); - validate_base(q, num_deps, d_deps); - validate_obj(q, src_mem); - validate_obj(q, dst_img); + validate_common(q, { src_mem, dst_img }, deps); hard_event *hev = new hard_event( q, CL_COMMAND_COPY_BUFFER_TO_IMAGE, deps, - soft_copy_op(d_q, - dst_mem, vector(dst_origin), - {{ 1, dst_img->row_pitch(), dst_img->slice_pitch() }}, - src_mem, {{ src_offset }}, + soft_copy_op(q, + &dst_img, vector(dst_origin), + {{ 1, dst_img.row_pitch(), dst_img.slice_pitch() }}, + &src_mem, {{ src_offset }}, {{ 0, 0, 0 }}, vector(region))); @@ -479,20 +464,20 @@ clEnqueueCopyBufferToImage(cl_command_queue d_q, } PUBLIC void * -clEnqueueMapBuffer(cl_command_queue d_q, cl_mem mem, cl_bool blocking, +clEnqueueMapBuffer(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, cl_map_flags flags, size_t offset, size_t size, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev, cl_int *r_errcode) try { auto &q = obj(d_q); + auto &mem = obj(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - validate_base(q, num_deps, d_deps); - validate_obj(q, mem); + validate_common(q, { mem }, deps); - if (offset > mem->size() || offset + size > mem->size()) + if (offset > mem.size() || offset + size > mem.size()) throw error(CL_INVALID_VALUE); - void *map = mem->resource(q).add_map( + void *map = mem.resource(q).add_map( q, flags, blocking, {{ offset }}, {{ size }}); ret_object(rd_ev, new hard_event(q, CL_COMMAND_MAP_BUFFER, deps)); @@ -505,20 +490,19 @@ clEnqueueMapBuffer(cl_command_queue d_q, cl_mem mem, cl_bool blocking, } PUBLIC void * -clEnqueueMapImage(cl_command_queue d_q, cl_mem mem, cl_bool blocking, +clEnqueueMapImage(cl_command_queue d_q, cl_mem d_mem, cl_bool blocking, cl_map_flags flags, const size_t *origin, const size_t *region, size_t *row_pitch, size_t *slice_pitch, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev, cl_int *r_errcode) try { auto &q = obj(d_q); + auto &img = obj<image>(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - image *img = dynamic_cast<image *>(mem); - validate_base(q, num_deps, d_deps); - validate_obj(q, img); + validate_common(q, { img }, deps); - void *map = img->resource(q).add_map( + void *map = img.resource(q).add_map( q, flags, blocking, vector(origin), vector(region)); ret_object(rd_ev, new hard_event(q, CL_COMMAND_MAP_IMAGE, deps)); @@ -531,19 +515,19 @@ clEnqueueMapImage(cl_command_queue d_q, cl_mem mem, cl_bool blocking, } PUBLIC cl_int -clEnqueueUnmapMemObject(cl_command_queue d_q, cl_mem mem, void *ptr, +clEnqueueUnmapMemObject(cl_command_queue d_q, cl_mem d_mem, void *ptr, cl_uint num_deps, const cl_event *d_deps, cl_event *rd_ev) try { auto &q = obj(d_q); + auto &mem = obj(d_mem); auto deps = objs<wait_list_tag>(d_deps, num_deps); - validate_base(q, num_deps, d_deps); - validate_obj(q, mem); + validate_common(q, { mem }, deps); hard_event *hev = new hard_event( q, CL_COMMAND_UNMAP_MEM_OBJECT, deps, [=, &q, &mem](event &) { - mem->resource(q).del_map(ptr); + mem.resource(q).del_map(ptr); }); ret_object(rd_ev, hev); diff --git a/src/gallium/state_trackers/clover/core/error.hpp b/src/gallium/state_trackers/clover/core/error.hpp index 088bdac3ef3..256b61be438 100644 --- a/src/gallium/state_trackers/clover/core/error.hpp +++ b/src/gallium/state_trackers/clover/core/error.hpp @@ -35,7 +35,7 @@ namespace clover { class hard_event; class soft_event; class kernel; - typedef struct _cl_mem memory_obj; + class memory_obj; class buffer; class root_buffer; class sub_buffer; diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp index 9f9577b1921..b98a0ba5691 100644 --- a/src/gallium/state_trackers/clover/core/kernel.cpp +++ b/src/gallium/state_trackers/clover/core/kernel.cpp @@ -305,10 +305,7 @@ kernel::global_argument::set(size_t size, const void *value) { if (size != sizeof(cl_mem)) throw error(CL_INVALID_ARG_SIZE); - buf = dynamic_cast<buffer *>(*(cl_mem *)value); - if (!buf) - throw error(CL_INVALID_MEM_OBJECT); - + buf = &obj<buffer>(*(cl_mem *)value); _set = true; } @@ -360,10 +357,7 @@ kernel::constant_argument::set(size_t size, const void *value) { if (size != sizeof(cl_mem)) throw error(CL_INVALID_ARG_SIZE); - buf = dynamic_cast<buffer *>(*(cl_mem *)value); - if (!buf) - throw error(CL_INVALID_MEM_OBJECT); - + buf = &obj<buffer>(*(cl_mem *)value); _set = true; } @@ -391,10 +385,7 @@ kernel::image_rd_argument::set(size_t size, const void *value) { if (size != sizeof(cl_mem)) throw error(CL_INVALID_ARG_SIZE); - img = dynamic_cast<image *>(*(cl_mem *)value); - if (!img) - throw error(CL_INVALID_MEM_OBJECT); - + img = &obj<image>(*(cl_mem *)value); _set = true; } @@ -422,10 +413,7 @@ kernel::image_wr_argument::set(size_t size, const void *value) { if (size != sizeof(cl_mem)) throw error(CL_INVALID_ARG_SIZE); - img = dynamic_cast<image *>(*(cl_mem *)value); - if (!img) - throw error(CL_INVALID_MEM_OBJECT); - + img = &obj<image>(*(cl_mem *)value); _set = true; } diff --git a/src/gallium/state_trackers/clover/core/memory.cpp b/src/gallium/state_trackers/clover/core/memory.cpp index 38da67b8fef..106936bef56 100644 --- a/src/gallium/state_trackers/clover/core/memory.cpp +++ b/src/gallium/state_trackers/clover/core/memory.cpp @@ -25,8 +25,8 @@ using namespace clover; -_cl_mem::_cl_mem(clover::context &ctx, cl_mem_flags flags, - size_t size, void *host_ptr) : +memory_obj::memory_obj(context &ctx, cl_mem_flags flags, + size_t size, void *host_ptr) : ctx(ctx), _flags(flags), _size(size), _host_ptr(host_ptr), _destroy_notify([]{}) { @@ -34,31 +34,31 @@ _cl_mem::_cl_mem(clover::context &ctx, cl_mem_flags flags, data.append((char *)host_ptr, size); } -_cl_mem::~_cl_mem() { +memory_obj::~memory_obj() { _destroy_notify(); } void -_cl_mem::destroy_notify(std::function<void ()> f) { +memory_obj::destroy_notify(std::function<void ()> f) { _destroy_notify = f; } cl_mem_flags -_cl_mem::flags() const { +memory_obj::flags() const { return _flags; } size_t -_cl_mem::size() const { +memory_obj::size() const { return _size; } void * -_cl_mem::host_ptr() const { +memory_obj::host_ptr() const { return _host_ptr; } -buffer::buffer(clover::context &ctx, cl_mem_flags flags, +buffer::buffer(context &ctx, cl_mem_flags flags, size_t size, void *host_ptr) : memory_obj(ctx, flags, size, host_ptr) { } @@ -68,12 +68,12 @@ buffer::type() const { return CL_MEM_OBJECT_BUFFER; } -root_buffer::root_buffer(clover::context &ctx, cl_mem_flags flags, +root_buffer::root_buffer(context &ctx, cl_mem_flags flags, size_t size, void *host_ptr) : buffer(ctx, flags, size, host_ptr) { } -clover::resource & +resource & root_buffer::resource(command_queue &q) { // Create a new resource if there's none for this device yet. if (!resources.count(&q.dev)) { @@ -89,14 +89,14 @@ root_buffer::resource(command_queue &q) { return *resources.find(&q.dev)->second; } -sub_buffer::sub_buffer(clover::root_buffer &parent, cl_mem_flags flags, +sub_buffer::sub_buffer(root_buffer &parent, cl_mem_flags flags, size_t offset, size_t size) : buffer(parent.ctx, flags, size, (char *)parent.host_ptr() + offset), parent(parent), _offset(offset) { } -clover::resource & +resource & sub_buffer::resource(command_queue &q) { // Create a new resource if there's none for this device yet. if (!resources.count(&q.dev)) { @@ -114,7 +114,7 @@ sub_buffer::offset() const { return _offset; } -image::image(clover::context &ctx, cl_mem_flags flags, +image::image(context &ctx, cl_mem_flags flags, const cl_image_format *format, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, size_t size, @@ -124,7 +124,7 @@ image::image(clover::context &ctx, cl_mem_flags flags, _row_pitch(row_pitch), _slice_pitch(slice_pitch) { } -clover::resource & +resource & image::resource(command_queue &q) { // Create a new resource if there's none for this device yet. if (!resources.count(&q.dev)) { @@ -170,7 +170,7 @@ image::slice_pitch() const { return _slice_pitch; } -image2d::image2d(clover::context &ctx, cl_mem_flags flags, +image2d::image2d(context &ctx, cl_mem_flags flags, const cl_image_format *format, size_t width, size_t height, size_t row_pitch, void *host_ptr) : @@ -183,7 +183,7 @@ image2d::type() const { return CL_MEM_OBJECT_IMAGE2D; } -image3d::image3d(clover::context &ctx, cl_mem_flags flags, +image3d::image3d(context &ctx, cl_mem_flags flags, const cl_image_format *format, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, diff --git a/src/gallium/state_trackers/clover/core/memory.hpp b/src/gallium/state_trackers/clover/core/memory.hpp index de0b531a9d3..7c5300899ef 100644 --- a/src/gallium/state_trackers/clover/core/memory.hpp +++ b/src/gallium/state_trackers/clover/core/memory.hpp @@ -31,89 +31,85 @@ #include "core/queue.hpp" namespace clover { - typedef struct _cl_mem memory_obj; - class resource; class sub_resource; -} -struct _cl_mem : public clover::ref_counter { -protected: - _cl_mem(clover::context &ctx, cl_mem_flags flags, - size_t size, void *host_ptr); - _cl_mem(const _cl_mem &obj) = delete; + class memory_obj : public ref_counter, public _cl_mem { + protected: + memory_obj(context &ctx, cl_mem_flags flags, + size_t size, void *host_ptr); + memory_obj(const memory_obj &obj) = delete; -public: - virtual ~_cl_mem(); + public: + virtual ~memory_obj(); - virtual cl_mem_object_type type() const = 0; - virtual clover::resource &resource(clover::command_queue &q) = 0; + virtual cl_mem_object_type type() const = 0; + virtual clover::resource &resource(command_queue &q) = 0; - void destroy_notify(std::function<void ()> f); - cl_mem_flags flags() const; - size_t size() const; - void *host_ptr() const; + void destroy_notify(std::function<void ()> f); + cl_mem_flags flags() const; + size_t size() const; + void *host_ptr() const; - clover::context &ctx; + context &ctx; -private: - cl_mem_flags _flags; - size_t _size; - void *_host_ptr; - std::function<void ()> _destroy_notify; + private: + cl_mem_flags _flags; + size_t _size; + void *_host_ptr; + std::function<void ()> _destroy_notify; -protected: - std::string data; -}; + protected: + std::string data; + }; -namespace clover { - struct buffer : public memory_obj { + class buffer : public memory_obj { protected: - buffer(clover::context &ctx, cl_mem_flags flags, + buffer(context &ctx, cl_mem_flags flags, size_t size, void *host_ptr); public: virtual cl_mem_object_type type() const; }; - struct root_buffer : public buffer { + class root_buffer : public buffer { public: - root_buffer(clover::context &ctx, cl_mem_flags flags, + root_buffer(context &ctx, cl_mem_flags flags, size_t size, void *host_ptr); - virtual clover::resource &resource(clover::command_queue &q); + virtual clover::resource &resource(command_queue &q); private: - std::map<clover::device *, - std::unique_ptr<clover::root_resource>> resources; + std::map<device *, + std::unique_ptr<root_resource>> resources; }; - struct sub_buffer : public buffer { + class sub_buffer : public buffer { public: - sub_buffer(clover::root_buffer &parent, cl_mem_flags flags, + sub_buffer(root_buffer &parent, cl_mem_flags flags, size_t offset, size_t size); - virtual clover::resource &resource(clover::command_queue &q); + virtual clover::resource &resource(command_queue &q); size_t offset() const; - clover::root_buffer &parent; + root_buffer &parent; private: size_t _offset; - std::map<clover::device *, - std::unique_ptr<clover::sub_resource>> resources; + std::map<device *, + std::unique_ptr<sub_resource>> resources; }; - struct image : public memory_obj { + class image : public memory_obj { protected: - image(clover::context &ctx, cl_mem_flags flags, + image(context &ctx, cl_mem_flags flags, const cl_image_format *format, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, size_t size, void *host_ptr); public: - virtual clover::resource &resource(clover::command_queue &q); + virtual clover::resource &resource(command_queue &q); cl_image_format format() const; size_t width() const; size_t height() const; @@ -128,13 +124,13 @@ namespace clover { size_t _depth; size_t _row_pitch; size_t _slice_pitch; - std::map<clover::device *, - std::unique_ptr<clover::root_resource>> resources; + std::map<device *, + std::unique_ptr<root_resource>> resources; }; - struct image2d : public image { + class image2d : public image { public: - image2d(clover::context &ctx, cl_mem_flags flags, + image2d(context &ctx, cl_mem_flags flags, const cl_image_format *format, size_t width, size_t height, size_t row_pitch, void *host_ptr); @@ -142,9 +138,9 @@ namespace clover { virtual cl_mem_object_type type() const; }; - struct image3d : public image { + class image3d : public image { public: - image3d(clover::context &ctx, cl_mem_flags flags, + image3d(context &ctx, cl_mem_flags flags, const cl_image_format *format, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, diff --git a/src/gallium/state_trackers/clover/core/object.hpp b/src/gallium/state_trackers/clover/core/object.hpp index 9c2180f3b29..461ccb0ceec 100644 --- a/src/gallium/state_trackers/clover/core/object.hpp +++ b/src/gallium/state_trackers/clover/core/object.hpp @@ -191,6 +191,9 @@ struct _cl_event : struct _cl_kernel : public clover::descriptor<clover::kernel, _cl_kernel> {}; +struct _cl_mem : + public clover::descriptor<clover::memory_obj, _cl_mem> {}; + struct _cl_platform_id : public clover::descriptor<clover::platform, _cl_platform_id> {}; diff --git a/src/gallium/state_trackers/clover/core/resource.cpp b/src/gallium/state_trackers/clover/core/resource.cpp index 2121268cd8f..c503c86d771 100644 --- a/src/gallium/state_trackers/clover/core/resource.cpp +++ b/src/gallium/state_trackers/clover/core/resource.cpp @@ -21,7 +21,6 @@ // #include "core/resource.hpp" -#include "util/algorithm.hpp" #include "pipe/p_screen.h" #include "util/u_sampler.h" #include "util/u_format.h" @@ -46,7 +45,7 @@ namespace { }; } -resource::resource(clover::device &dev, clover::memory_obj &obj) : +resource::resource(device &dev, memory_obj &obj) : dev(dev), obj(obj), pipe(NULL), offset() { } @@ -83,7 +82,7 @@ resource::map_count() const { } pipe_sampler_view * -resource::bind_sampler_view(clover::command_queue &q) { +resource::bind_sampler_view(command_queue &q) { pipe_sampler_view info; u_sampler_view_default_template(&info, pipe, pipe->format); @@ -91,13 +90,13 @@ resource::bind_sampler_view(clover::command_queue &q) { } void -resource::unbind_sampler_view(clover::command_queue &q, +resource::unbind_sampler_view(command_queue &q, pipe_sampler_view *st) { q.pipe->sampler_view_destroy(q.pipe, st); } pipe_surface * -resource::bind_surface(clover::command_queue &q, bool rw) { +resource::bind_surface(command_queue &q, bool rw) { pipe_surface info {}; info.format = pipe->format; @@ -110,13 +109,12 @@ resource::bind_surface(clover::command_queue &q, bool rw) { } void -resource::unbind_surface(clover::command_queue &q, pipe_surface *st) { +resource::unbind_surface(command_queue &q, pipe_surface *st) { q.pipe->surface_destroy(q.pipe, st); } -root_resource::root_resource(clover::device &dev, clover::memory_obj &obj, - clover::command_queue &q, - const std::string &data) : +root_resource::root_resource(device &dev, memory_obj &obj, + command_queue &q, const std::string &data) : resource(dev, obj) { pipe_resource info {}; @@ -152,8 +150,8 @@ root_resource::root_resource(clover::device &dev, clover::memory_obj &obj, } } -root_resource::root_resource(clover::device &dev, clover::memory_obj &obj, - clover::root_resource &r) : +root_resource::root_resource(device &dev, memory_obj &obj, + root_resource &r) : resource(dev, obj) { assert(0); // XXX -- resource shared among dev and r.dev } diff --git a/src/gallium/state_trackers/clover/core/resource.hpp b/src/gallium/state_trackers/clover/core/resource.hpp index 8fcfb496a33..99e509a63b1 100644 --- a/src/gallium/state_trackers/clover/core/resource.hpp +++ b/src/gallium/state_trackers/clover/core/resource.hpp @@ -52,22 +52,22 @@ namespace clover { void del_map(void *p); unsigned map_count() const; - clover::device &dev; - clover::memory_obj &obj; + device &dev; + memory_obj &obj; friend class sub_resource; friend class mapping; friend class kernel; protected: - resource(clover::device &dev, clover::memory_obj &obj); + resource(device &dev, clover::memory_obj &obj); - pipe_sampler_view *bind_sampler_view(clover::command_queue &q); - void unbind_sampler_view(clover::command_queue &q, + pipe_sampler_view *bind_sampler_view(command_queue &q); + void unbind_sampler_view(command_queue &q, pipe_sampler_view *st); - pipe_surface *bind_surface(clover::command_queue &q, bool rw); - void unbind_surface(clover::command_queue &q, pipe_surface *st); + pipe_surface *bind_surface(command_queue &q, bool rw); + void unbind_surface(command_queue &q, pipe_surface *st); pipe_resource *pipe; vector offset; @@ -82,9 +82,9 @@ namespace clover { /// class root_resource : public resource { public: - root_resource(clover::device &dev, clover::memory_obj &obj, - clover::command_queue &q, const std::string &data); - root_resource(clover::device &dev, clover::memory_obj &obj, + root_resource(device &dev, memory_obj &obj, + command_queue &q, const std::string &data); + root_resource(device &dev, memory_obj &obj, root_resource &r); virtual ~root_resource(); }; @@ -95,7 +95,7 @@ namespace clover { /// class sub_resource : public resource { public: - sub_resource(clover::resource &r, const vector &offset); + sub_resource(resource &r, const vector &offset); }; /// |