| 198 | } |
| 199 | |
| 200 | void PipelineBuilder::build_graph( |
| 201 | const Vector<StringName> &p_system_bundles, |
| 202 | const Vector<StringName> &p_systems, |
| 203 | ExecutionGraph *r_graph, |
| 204 | bool p_skip_warnings) { |
| 205 | CRASH_COND_MSG(r_graph == nullptr, "The pipeline pointer must be valid."); |
| 206 | |
| 207 | r_graph->valid = false; |
| 208 | r_graph->error_msg = ""; |
| 209 | r_graph->warnings.clear(); |
| 210 | r_graph->systems.clear(); |
| 211 | r_graph->dispatchers.clear(); |
| 212 | r_graph->systems_dispatcher.clear(); |
| 213 | |
| 214 | // Crate the main dispatcher. |
| 215 | Ref<ExecutionGraph::Dispatcher> main; |
| 216 | main.instantiate(); |
| 217 | r_graph->dispatchers.insert("main", main); |
| 218 | |
| 219 | // Initialize the system, by fetching the various dependencies. |
| 220 | r_graph->systems.resize(ECS::get_systems_count()); |
| 221 | |
| 222 | fetch_bundle_info(p_system_bundles, r_graph); |
| 223 | for (int i = 0; i < p_systems.size(); i += 1) { |
| 224 | fetch_system_info(p_systems[i], StringName(), -1, LocalVector<SystemDependency>(), r_graph); |
| 225 | } |
| 226 | |
| 227 | String error; |
| 228 | const bool sort_failed = !sort_systems(r_graph, error); |
| 229 | |
| 230 | // Check if we have a cynclic dependency. |
| 231 | if (sort_failed || has_cyclick_dependencies(r_graph, error)) { |
| 232 | r_graph->print_sorted_systems(); |
| 233 | r_graph->print_stages(); |
| 234 | |
| 235 | r_graph->systems_dispatcher.clear(); |
| 236 | r_graph->dispatchers.clear(); |
| 237 | r_graph->systems.clear(); |
| 238 | r_graph->valid = false; |
| 239 | r_graph->error_msg = error; |
| 240 | r_graph->error_msg += TTR(" Pipeline building is aborted."); |
| 241 | |
| 242 | ERR_FAIL_MSG("[FATAL] " + r_graph->error_msg + " Check the pipeline above ---^"); |
| 243 | return; |
| 244 | } |
| 245 | |
| 246 | // The validation phase |
| 247 | if (!p_skip_warnings) { |
| 248 | detect_warnings_sub_dispatchers_missing(r_graph); |
| 249 | detect_warnings_lost_events(r_graph); |
| 250 | } |
| 251 | |
| 252 | // Everything is fine, build the graph and optimize it. |
| 253 | build_stages(r_graph); |
| 254 | optimize_stages(r_graph); |
| 255 | |
| 256 | r_graph->valid = true; |
| 257 |
nothing calls this directly
no test coverage detected