Skip to content
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

res_index modulation #708

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion src/iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ bool ecs_worker_next_instanced(

ecs_iter_t *chain_it = it->chain_it;
ecs_worker_iter_t *iter = &it->priv.iter.worker;
int32_t res_count = iter->count, res_index = iter->index;
int32_t res_count = iter->count;
int32_t per_worker, instances_per_worker, first;

do {
Expand All @@ -1058,6 +1058,9 @@ bool ecs_worker_next_instanced(

/* Keep instancing setting from original iterator */
ECS_BIT_COND(it->flags, EcsIterIsInstanced, instanced);

uint64_t table_id = it->table ? it->table->id : 0;
int32_t res_index = (int32_t)((UINT64_C(11400714819323198485) * table_id + (uint64_t)iter->index) % (uint64_t)res_count);

int32_t count = it->count;
int32_t instance_count = it->instance_count;
Expand Down