MCPcopy Create free account
hub / github.com/Ipotrick/Daxa / create_buffer_helper

Function create_buffer_helper

src/utils/impl_task_graph.cpp:950–985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

948 }
949
950 auto create_buffer_helper(ImplTaskGraph & impl, TaskResourceKind kind, usize size, TaskResourceLifetimeType lifetime_type, std::string_view name)
951 {
952 DAXA_DBG_ASSERT_TRUE_M(!impl.compiled, "completed task graphs can not record new tasks");
953 DAXA_DBG_ASSERT_TRUE_M(!impl.name_to_resource_table.contains(name), "task buffer names must be unique");
954
955 ImplTaskResource buffer = {};
956 buffer.name = impl.task_memory.allocate_copy_string(name);
957 buffer.kind = kind;
958 buffer.external = {};
959 buffer.lifetime_type = lifetime_type,
960 buffer.id = {};
961 buffer.info.buffer.size = size;
962
963 impl.resources.push_back(buffer);
964 u32 const index = static_cast<u32>(impl.resources.size()) - 1u;
965
966 impl.name_to_resource_table[buffer.name] = std::pair{&impl.resources.back(), index};
967
968 if (lifetime_type == TaskResourceLifetimeType::PERSISTENT_DOUBLE_BUFFER)
969 {
970 auto buffer_back_buffer = buffer;
971 buffer_back_buffer.name = impl.task_memory.allocate_copy_string(std::format("{}::back_buffer", name).c_str());
972
973 impl.resources.push_back(buffer_back_buffer);
974 u32 const back_buffer_resource_index = static_cast<u32>(impl.resources.size()) - 1u;
975
976 impl.name_to_resource_table[buffer_back_buffer.name] = std::pair{&impl.resources.back(), back_buffer_resource_index};
977
978 impl.resources[index].double_buffer_pair_resource = { &impl.resources.back(), back_buffer_resource_index };
979 impl.resources[index].double_buffer_index = 0u;
980 impl.resources[back_buffer_resource_index].double_buffer_pair_resource = { (&impl.resources.back()) - 1u, index };
981 impl.resources[back_buffer_resource_index].double_buffer_index = 1u;
982 }
983
984 return index;
985 }
986
987 auto TaskGraph::create_task_buffer(TaskBufferInfo info) -> TaskBufferView
988 {

Callers 2

create_task_bufferMethod · 0.70
create_task_tlasMethod · 0.70

Calls 6

containsMethod · 0.80
allocate_copy_stringMethod · 0.80
c_strMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected