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

Method clone

compute/compute_buffer.cpp:228–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228shared_ptr<compute_buffer> compute_buffer::clone(const compute_queue& cqueue, const bool copy_contents,
229 const COMPUTE_MEMORY_FLAG flags_override) {
230 if (dev.context == nullptr) {
231 log_error("invalid buffer/device state");
232 return {};
233 }
234
235 auto clone_flags = (flags_override != COMPUTE_MEMORY_FLAG::NONE ? flags_override : flags);
236 shared_ptr<compute_buffer> ret;
237 if (host_data.data() != nullptr) {
238 // never copy host data on the newly created buffer
239 clone_flags |= COMPUTE_MEMORY_FLAG::NO_INITIAL_COPY;
240 assert(size == host_data.size_bytes());
241 ret = dev.context->create_buffer(cqueue, host_data, clone_flags, opengl_type);
242 } else {
243 ret = dev.context->create_buffer(cqueue, size, clone_flags, opengl_type);
244 }
245 if (ret == nullptr) {
246 return {};
247 }
248
249 if (copy_contents) {
250 ret->copy(cqueue, *this);
251 }
252
253 return ret;
254}
255
256const metal_buffer* compute_buffer::get_underlying_metal_buffer_safe() const {
257 if (has_flag<COMPUTE_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