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

Method create_internal

src/device/host/host_buffer.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61bool host_buffer::create_internal(const bool copy_host_data, const device_queue& cqueue) {
62 // TODO: handle the remaining flags + host ptr
63
64 // always allocate host memory (even with Metal/Vulkan, memory needs to be copied somewhere)
65 buffer = make_aligned_ptr<uint8_t>(size);
66
67 // -> normal host buffer
68 if (!has_flag<MEMORY_FLAG::METAL_SHARING>(flags) &&
69 !has_flag<MEMORY_FLAG::VULKAN_SHARING>(flags)) {
70 // copy host memory to "device" if it is non-null and NO_INITIAL_COPY is not specified
71 if (copy_host_data &&
72 host_data.data() != nullptr &&
73 !has_flag<MEMORY_FLAG::NO_INITIAL_COPY>(flags)) {
74 memcpy(buffer.get(), host_data.data(), size);
75 }
76 }
77#if !defined(FLOOR_NO_METAL)
78 // -> shared host <-> Metal buffer
79 else if (has_flag<MEMORY_FLAG::METAL_SHARING>(flags)) {
80 if (!create_shared_buffer(copy_host_data)) {
81 return false;
82 }
83
84 // acquire for use with the host
85 const device_queue* comp_mtl_queue = get_default_queue_for_memory(*shared_buffer);
86 acquire_metal_buffer(&cqueue, (const metal_queue*)comp_mtl_queue);
87 }
88#endif
89#if !defined(FLOOR_NO_VULKAN)
90 // -> shared host <-> Vulkan buffer
91 else if (has_flag<MEMORY_FLAG::VULKAN_SHARING>(flags)) {
92 if (!create_shared_buffer(copy_host_data)) {
93 return false;
94 }
95
96 // acquire for use with the host
97 const device_queue* comp_vk_queue = get_default_queue_for_memory(*shared_buffer);
98 acquire_vulkan_buffer(&cqueue, (const vulkan_queue*)comp_vk_queue);
99 }
100#endif
101
102 return true;
103}
104
105host_buffer::~host_buffer() {
106}

Callers

nothing calls this directly

Calls 2

dataMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected