Repository navigation
meshletcodec: Revise encoding format for slightly more compression - #1006
Merged
Merged
Conversation
Instead of storing vertex control bits last, we now store triangle codes last in the encoded meshlet. This is mostly motivated by a slight improvement in the resulting compression rates (~1%) after zstd/zlib compression gets applied, but it's also beneficial in other ways: this order now matches the order of variable data encoding, and because the first triangle must start with a restart code, it may make it easier to validate or potentially version data in the future (although other changes might be necessary for that to happen).
Because our deltas are offset by 1, it takes one byte to encode the delta value of 0, and zero bytes to encode the delta value of 1. If meshlets encode absolute vertex references, this only affects the first meshlet so it's inconseqeuential. However, it's common to use relative encoding, storing a single base per meshlet - in which case, optimally ordered meshlets usually start with vertex reference 0. Starting the state with -1 means we can encode first vertex reference with zero bytes if it's 0; previously it would be encoded with zero bytes if it's 1, which is much less likely. This saves ~0.1 bits/tri in affected scenarios at zero cost.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
The data format continues to be highly experimental. Until a library point release, data compatibility is not guaranteed.
This contribution is sponsored by Valve.