MCPcopy Create free account
hub / github.com/a2flo/floor / clone

Method clone

src/device/device_buffer.cpp:66–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66std::shared_ptr<device_buffer> device_buffer::clone(const device_queue& cqueue, const bool copy_contents,
67 const MEMORY_FLAG flags_override) {
68 if (dev.context == nullptr) {
69 log_error("invalid buffer/device state");
70 return {};
71 }
72
73 auto clone_flags = (flags_override != MEMORY_FLAG::NONE ? flags_override : flags);
74 std::shared_ptr<device_buffer> ret;
75 if (host_data.data() != nullptr) {
76 // never copy host data on the newly created buffer
77 clone_flags |= MEMORY_FLAG::NO_INITIAL_COPY;
78 assert(size == host_data.size_bytes());
79 ret = dev.context->create_buffer(cqueue, host_data, clone_flags);
80 } else {
81 ret = dev.context->create_buffer(cqueue, size, clone_flags);
82 }
83 if (ret && copy_contents) {
84 ret->copy(cqueue, *this);
85 }
86 return ret;
87}
88
89const metal_buffer* device_buffer::get_underlying_metal_buffer_safe() const {
90 if (has_flag<MEMORY_FLAG::METAL_SHARING>(flags)) {

Callers

nothing calls this directly

Calls 3

dataMethod · 0.45
create_bufferMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected