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

Is Bincode The Best Serialization Format for Cooked Shader Packages? #168

Closed
zicklag opened this issue Jun 15, 2021 · 1 comment
Closed

Comments

@zicklag
Copy link
Contributor

zicklag commented Jun 15, 2021

Related to a comment ( bincode-org/bincode#221 (comment) ) in the bincode repository ( emphasis mine ):

I think you put it well in that this is mainly supposed to be used internally by Rust programs; I might go further and say that it should only be used by the same program because you must be sure that the serialization and deserialization must be implemented exactly the same.

I'm just wondering if, due to the instability of the format maybe it would be more suitable to use a format like CBOR that will be stable regardless of which version of bincode Rust, etc. that is used to cook the shaders.

It seems like it would be a really easy change to make.

Maybe we don't technically need the stability, but I'm immagining a situation where the baked shaders are commited to git, and then you upgrade your project without updating the shaders, and now the baked shaders fail to load. Even in that case, I suppose you would probably know right away that its because you need to re-compile your shaders.

The disadvantage of CBOR would be that it is less compact than bincode, which I just realized is also used for assets, where the compactness is probably a bigger deal.


On another note, there's also rkyv if we want a zero-copy format, but it doesn't natively handle different endianness.


Let me know if I'm just being annoying by bringing up ideas for changes when I've hardly used the library or gotten a solid understanding of what's best for the project yet. ;) It helps me identify project priorities and what the general design preferences are when I get into a new project.

@aclysma
Copy link
Owner

aclysma commented Jun 15, 2021

The long term plan is that distill will read shader files directly, although it’s unclear how that would work with the rust code generation. This can not be done right now because a distill import currently cannot look at multiple files when importing an asset, and shaders can #include other shaders.

At some point I’d like to have a common wrapper around all binary data identifying a type/version of a format. I don’t think it’s worth changing the format to something else right now. But this topic might come up again when I start looking at exporting binary data from blender and importing it with distill.

@aclysma aclysma closed this as completed Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants