MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / update_dependencies

Method update_dependencies

modules/engine/runtime/src/ecs/scheduler.cpp:562–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560}
561
562skr::stl_vector<skr::task::weak_event_t> sugoi::scheduler_t::update_dependencies(sugoi_query_t* query, const skr::task::event_t& counter, sugoi_resource_operation_t* resources)
563{
564 SkrZoneScopedN("SchesugoiCustomJob");
565
566 llvm_vecsmall::SmallVector<sugoi_group_t*, 64> groups;
567 auto add_group = [&](sugoi_group_t* group) {
568 groups.push_back(group);
569 };
570 query->storage->query_groups(query->filter, query->meta, SUGOI_LAMBDA(add_group));
571 auto& params = query->parameters;
572 DependencySet dependencies;
573
574 if (resources)
575 {
576 SkrZoneScopedN("UpdateResourcesEntries");
577 SMutexLock resourceLock(resourceMutex.mMutex);
578 forloop (i, 0, resources->count)
579 {
580 auto& entry = allResources[e_id(resources->resources[i])];
581 auto readonly = resources->readonly[i];
582 auto atomic = resources->atomic[i];
583 update_entry(entry, counter, readonly, atomic, dependencies);
584 }
585 }
586
587 skr::FlatHashSet<std::pair<sugoi::archetype_t*, sugoi_type_index_t>> syncedEntry;
588 auto sync_entry = [&](const sugoi_group_t* group, sugoi_type_index_t localType, bool readonly, bool atomic) {
589 if (localType == kInvalidTypeIndex)
590 return;
591 auto at = group->archetype;
592 auto pair = std::make_pair(at, localType);
593 if (syncedEntry.find(pair) != syncedEntry.end())
594 return;
595 syncedEntry.insert(pair);
596 {
597 SMutexLock entryLock(entryMutex.mMutex);
598 auto iter = dependencyEntries.find(at);
599 if (iter == dependencyEntries.end())
600 {
601 skr::stl_vector<job_dependency_entry_t> entries(at->type.length);
602 iter = dependencyEntries.insert(std::make_pair(at, std::move(entries))).first;
603 }
604
605 auto entries = (*iter).second.data();
606 auto& entry = entries[localType];
607 update_entry(entry, counter, readonly, atomic, dependencies);
608 }
609 };
610
611 auto sync_type = [&](sugoi_type_index_t type, bool readonly, bool atomic) {
612 for (auto& pair : query->storage->groups)
613 {
614 auto group = pair.second;
615 auto idx = group->index(type);
616 sync_entry(group, idx, readonly, atomic);
617 }
618 };
619

Callers

nothing calls this directly

Calls 12

update_entryFunction · 0.85
type_index_tClass · 0.85
query_groupsMethod · 0.80
is_tagMethod · 0.80
get_ownerMethod · 0.80
moveFunction · 0.50
push_backMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
dataMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected