clover: Implement CL_MEM_COPY_HOST_PTR.
This commit is contained in:
@@ -29,8 +29,9 @@ _cl_mem::_cl_mem(clover::context &ctx, cl_mem_flags flags,
|
||||
size_t size, void *host_ptr) :
|
||||
ctx(ctx), __flags(flags),
|
||||
__size(size), __host_ptr(host_ptr),
|
||||
__destroy_notify([]{}),
|
||||
data((char *)host_ptr, (host_ptr ? size : 0)) {
|
||||
__destroy_notify([]{}) {
|
||||
if (flags & CL_MEM_COPY_HOST_PTR)
|
||||
data.append((char *)host_ptr, size);
|
||||
}
|
||||
|
||||
_cl_mem::~_cl_mem() {
|
||||
@@ -78,7 +79,7 @@ root_buffer::resource(cl_command_queue q) {
|
||||
if (!resources.count(&q->dev)) {
|
||||
auto r = (!resources.empty() ?
|
||||
new root_resource(q->dev, *this, *resources.begin()->second) :
|
||||
new root_resource(q->dev, *this, data));
|
||||
new root_resource(q->dev, *this, *q, data));
|
||||
|
||||
resources.insert(std::make_pair(&q->dev,
|
||||
std::unique_ptr<root_resource>(r)));
|
||||
@@ -129,7 +130,7 @@ image::resource(cl_command_queue q) {
|
||||
if (!resources.count(&q->dev)) {
|
||||
auto r = (!resources.empty() ?
|
||||
new root_resource(q->dev, *this, *resources.begin()->second) :
|
||||
new root_resource(q->dev, *this, data));
|
||||
new root_resource(q->dev, *this, *q, data));
|
||||
|
||||
resources.insert(std::make_pair(&q->dev,
|
||||
std::unique_ptr<root_resource>(r)));
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
clover::device &dev;
|
||||
|
||||
friend class clover::resource;
|
||||
friend class clover::root_resource;
|
||||
friend class clover::mapping;
|
||||
friend class clover::hard_event;
|
||||
friend struct _cl_sampler;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "core/resource.hpp"
|
||||
#include "pipe/p_screen.h"
|
||||
#include "util/u_sampler.h"
|
||||
#include "util/u_format.h"
|
||||
|
||||
using namespace clover;
|
||||
|
||||
@@ -114,7 +115,8 @@ resource::unbind_surface(clover::command_queue &q, pipe_surface *st) {
|
||||
}
|
||||
|
||||
root_resource::root_resource(clover::device &dev, clover::memory_obj &obj,
|
||||
std::string data) :
|
||||
clover::command_queue &q,
|
||||
const std::string &data) :
|
||||
resource(dev, obj) {
|
||||
pipe_resource info {};
|
||||
|
||||
@@ -125,6 +127,8 @@ root_resource::root_resource(clover::device &dev, clover::memory_obj &obj,
|
||||
info.depth0 = img->depth();
|
||||
} else {
|
||||
info.width0 = obj.size();
|
||||
info.height0 = 1;
|
||||
info.depth0 = 1;
|
||||
}
|
||||
|
||||
info.target = translate_target(obj.type());
|
||||
@@ -138,7 +142,14 @@ root_resource::root_resource(clover::device &dev, clover::memory_obj &obj,
|
||||
if (!pipe)
|
||||
throw error(CL_OUT_OF_RESOURCES);
|
||||
|
||||
assert(data.empty()); // XXX -- initialize it with the supplied data
|
||||
if (!data.empty()) {
|
||||
box rect { { 0, 0, 0 }, { info.width0, info.height0, info.depth0 } };
|
||||
unsigned cpp = util_format_get_blocksize(info.format);
|
||||
|
||||
q.pipe->transfer_inline_write(q.pipe, pipe, 0, PIPE_TRANSFER_WRITE,
|
||||
rect, data.data(), cpp * info.width0,
|
||||
cpp * info.width0 * info.height0);
|
||||
}
|
||||
}
|
||||
|
||||
root_resource::root_resource(clover::device &dev, clover::memory_obj &obj,
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace clover {
|
||||
class root_resource : public resource {
|
||||
public:
|
||||
root_resource(clover::device &dev, clover::memory_obj &obj,
|
||||
std::string data);
|
||||
clover::command_queue &q, const std::string &data);
|
||||
root_resource(clover::device &dev, clover::memory_obj &obj,
|
||||
root_resource &r);
|
||||
virtual ~root_resource();
|
||||
|
||||
Reference in New Issue
Block a user