Skip to content

chore: system providers #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rt_entt_codegen/core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cc_library(
_CORE_CODEGEN_METHODS = {
"execute_systems": [
"//rt_entt_codegen/shared:parallel",
"//rt_entt_codegen/shared:system_variant",
],
"create_registry": [],
"entity_matches": [
Expand All @@ -26,6 +27,11 @@ _CORE_CODEGEN_METHODS = {
"//rt_entt_codegen/shared:system_util",
"//rt_entt_codegen/shared:parallel",
"//rt_entt_codegen/core/sys_exec",
"//rt_entt_codegen/core/system_provider:lazy",
"//rt_entt_codegen/core/system_provider:association",
"//rt_entt_codegen/core/system_provider:notify",
"//rt_entt_codegen/core/system_provider:basic",
"//rt_entt_codegen/core/system_provider",
"@entt//:entt",
"@ecsact_rt_entt//:lib",
],
Expand Down
73 changes: 18 additions & 55 deletions rt_entt_codegen/core/execute_systems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ecsact/lang-support/lang-cc.hh"
#include "rt_entt_codegen/shared/util.hh"
#include "ecsact/cpp_codegen_plugin_util.hh"
#include "rt_entt_codegen/shared/system_variant.hh"

constexpr auto METHOD_BODY_TOP = R"(
auto& registry = ecsact::entt::get_registry(registry_id);
Expand Down Expand Up @@ -77,66 +78,28 @@ auto ecsact::rt_entt_codegen::core::print_execute_systems( //
});
});

std::vector<system_like_id_variant> system_like_variants;

for(const auto sys_like_id : details.top_execution_order) {
if(details.is_system(sys_like_id)) {
system_like_variants.push_back(static_cast<ecsact_system_id>(sys_like_id)
);
} else if(details.is_action(sys_like_id)) {
system_like_variants.push_back(static_cast<ecsact_action_id>(sys_like_id)
);
}
}

auto parallel_system_cluster =
ecsact::rt_entt_codegen::parallel::get_parallel_execution_cluster(
ctx,
details,
details.top_execution_order
system_like_variants
);

for(const auto& systems_to_parallel : parallel_system_cluster) {
if(systems_to_parallel.size() == 1) {
auto sync_sys_id = systems_to_parallel[0];

auto sync_sys_name =
cpp_identifier(ecsact::meta::decl_full_name(sync_sys_id));

if(details.is_action(sync_sys_id)) {
ctx.write(std::format(
"ecsact::entt::execute_actions<{}>(registry, {}, "
"actions_map);\n",
sync_sys_name,
"nullptr"
));
}
if(details.is_system(sync_sys_id)) {
ctx.write(std::format(
"ecsact::entt::execute_system<{}>(registry, {}, "
"actions_map);\n",
sync_sys_name,
"nullptr"
));
}
continue;
}

ctx.write("execute_parallel_cluster(registry, nullptr, ");
ctx.write(std::format(
"std::array<exec_entry_t, {}> {{\n",
systems_to_parallel.size()
));
for(const auto system_like_id : systems_to_parallel) {
auto cpp_decl_name =
cpp_identifier(ecsact::meta::decl_full_name(system_like_id));

if(details.is_action(system_like_id)) {
ctx.write(
"\texec_entry_t{&ecsact::entt::execute_actions<",
cpp_decl_name,
">, actions_map},\n"
);
} else if(details.is_system(system_like_id)) {
ctx.write(
"\texec_entry_t{&ecsact::entt::execute_system<",
cpp_decl_name,
">, actions_map},\n"
);
} else {
ctx.write("// ??? unhandled ??? ", cpp_decl_name, "\n");
}
}
ctx.write("});\n");
}
ecsact::rt_entt_codegen::parallel::print_parallel_execution_cluster(
ctx,
parallel_system_cluster
);

ctx.write("\nupdate_all_beforechange_storage(registry_id);\n");
ctx.write("cleanup_system_notifies(registry_id);\n");
Expand Down
Loading