Skip to content

Commit

Permalink
feat: Tons of refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelwan committed May 31, 2024
1 parent 5e52a5d commit decf71b
Show file tree
Hide file tree
Showing 24 changed files with 1,268 additions and 1,468 deletions.
2 changes: 2 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 @@ -29,6 +30,7 @@ _CORE_CODEGEN_METHODS = {
"//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

0 comments on commit decf71b

Please sign in to comment.