Skip to content

Commit

Permalink
#1525 Fix issue where sync point wasn't inserted for InOutNone term
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens authored Jan 21, 2025
1 parent 4ce8b97 commit b0e71d9
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
2 changes: 1 addition & 1 deletion distr/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -53976,7 +53976,7 @@ bool flecs_pipeline_check_term(
(void)world;

ecs_term_ref_t *src = &term->src;
if (term->inout == EcsInOutNone || term->inout == EcsInOutFilter) {
if (term->inout == EcsInOutFilter) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/addons/pipeline/pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ bool flecs_pipeline_check_term(
(void)world;

ecs_term_ref_t *src = &term->src;
if (term->inout == EcsInOutNone || term->inout == EcsInOutFilter) {
if (term->inout == EcsInOutFilter) {
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion test/addons/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
"pipeline_init_no_system_term",
"disable_component_from_immediate_system",
"run_w_empty_query",
"run_w_0_src_query"
"run_w_0_src_query",
"inout_none_after_write"
]
}, {
"id": "SystemMisc",
Expand Down
51 changes: 51 additions & 0 deletions test/addons/src/Pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -3285,3 +3285,54 @@ void Pipeline_run_w_0_src_query(void) {

ecs_fini(world);
}

static
void AddPosition(ecs_iter_t *it) {
for (int i = 0; i < it->count; i ++) {
ecs_add(it->world, it->entities[i], Position);
}
}

static int check_position_invoked = 0;

static void CheckPosition(ecs_iter_t *it) {
for (int i = 0; i < it->count; i ++) {
test_assert(ecs_has(it->world, it->entities[i], Position));
check_position_invoked ++;
}
}

void Pipeline_inout_none_after_write(void) {
ecs_world_t *world = ecs_init();

ECS_COMPONENT_DEFINE(world, Position);
ECS_TAG(world, Foo);

ecs_system(world, {
.entity = ecs_entity(world, {
.add = ecs_ids(ecs_pair(EcsDependsOn, EcsOnUpdate))
}),
.query.terms = {{ Foo }, { ecs_id(Position), .src.id = EcsIsEntity, .inout = EcsOut }},
.callback = AddPosition
});

ecs_system(world, {
.entity = ecs_entity(world, {
.add = ecs_ids(ecs_pair(EcsDependsOn, EcsOnUpdate))
}),
.query.terms = { { ecs_id(Position), .inout = EcsInOutNone } },
.callback = CheckPosition
});

ecs_entity_t e1 = ecs_new_w(world, Foo);
ecs_add(world, e1, Position);
ecs_entity_t e2 = ecs_new_w(world, Foo);

ecs_progress(world, 0);

test_assert(ecs_has(world, e1, Position));
test_assert(ecs_has(world, e2, Position));
test_int(check_position_invoked, 2);

ecs_fini(world);
}
7 changes: 6 additions & 1 deletion test/addons/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void Pipeline_pipeline_init_no_system_term(void);
void Pipeline_disable_component_from_immediate_system(void);
void Pipeline_run_w_empty_query(void);
void Pipeline_run_w_0_src_query(void);
void Pipeline_inout_none_after_write(void);

// Testsuite 'SystemMisc'
void SystemMisc_invalid_not_without_id(void);
Expand Down Expand Up @@ -932,6 +933,10 @@ bake_test_case Pipeline_testcases[] = {
{
"run_w_0_src_query",
Pipeline_run_w_0_src_query
},
{
"inout_none_after_write",
Pipeline_inout_none_after_write
}
};

Expand Down Expand Up @@ -2560,7 +2565,7 @@ static bake_test_suite suites[] = {
"Pipeline",
NULL,
NULL,
85,
86,
Pipeline_testcases
},
{
Expand Down
1 change: 1 addition & 0 deletions test/core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,7 @@
"forward_up_flag_term_2",
"propagate_up_flag_term_1",
"propagate_up_flag_term_2",
"propagate_on_set_self_up",
"row_flag_term_1",
"row_flag_term_2",
"on_add_optional",
Expand Down

0 comments on commit b0e71d9

Please sign in to comment.