EmbarkStudios / texture-synthesis

🎨 Example-based texture synthesis written in Rust 🦀

Home Page:http://embark.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reproducible / deterministic seeding

dlight opened this issue · comments

Are there plans to provide guaranteed deterministic/reproducible seeding of generated textures? Perhaps with some performance hit.

Currently the seed method says the generated output may be slightly different because of indeterminacy of thread execution.

Right now, to achieve reproducible builds one needs to save generated textures; while this is probably a good idea for performance reasons, I would like to delete old textures with some confidence that I can get them back by running the program.

There are some techniques that can mitigate concurrency indeterminacy. One of them is to avoid interior mutability (like atomics and locks) and use something like Rayon's fork-join, which would always produce the same output regardless of thread execution order (edit: clarified that you don't actually need immutable data, you just need to have each memory location being written by just one thread). But I don't know how feasible would it be to apply them to texture-synthesis.

As a last resort, texture-synthesis could at least state in its documentation (in the seed method and/or elsewhere) that if one sets max_thread_count to 1, generation is guaranteed to be deterministic.

I think the documentation addition would be the easiest here, as it means you can get what you want at the cost of significantly increased times.